Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsLoaded function not working for me

Status
Not open for further replies.

crisis2007

Technical User
Apr 2, 2007
114
US
I am trying to prevent records from being edited in a pop up form when a different form is also open. More specifically, I want to prevent editing of the records on a subform SF_Stat (embedded in a parent form F_EventDetails) when another form F_Activity is open.

I have the following in a module that I retrieved from the NorthWind sample:

Function IsLoaded (ByVal strFormName As String) As Boolean

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
conObjStateClosed Then
If Forms (strFormName).CurrentView <> consDesignView Then
IsLoaded = True
End If
End If
End Function

On the "On Current" event of SF_Stat I placed the following:

If IsLoaded("Forms![F_Activity]") = True Then
Me.AllowEdits = False

It seems to work in reverse - that is it does allow edits. However if I change the above code to say
If IsLoaded("Forms![F_Activity]") = False
it stops me from editing.

Am I not looking at this right? Should I just use another method? I have worked on this for several hours and it just is not working the way I want. I would leave it alone but it also messes up another form that I use when creating new records.




 
Please disregard. I did get it to work. I changed
("Forms![F_Activity]")to just
("F_Activity") and it works correctly now.
 
Just an FYI -

If you have Access 2000 or above, you don't need the IsLoaded function because it is already built-in. You access it via:

CurrentProject.AllForms.Item.IsLoaded ("FormNameHere")



Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
In fact the syntax is:
If CurrentProject.AllForms("F_Activity").IsLoaded Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top