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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need an if statement to detect if a form is open 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hello
Im trying to use some code in access to detect if a popup form is open.
I have tried to use
If IsFormOpen (“formname”) then
“do what ever”
End if
When I trigger the event that will run this code I get an error message saying Sub or Function not defined. Im just wondering if it is because the IsformOpen method doesn’t exist of if I need to select a Specific Reference.
Any advice would be greatly appreciated thanks.
 
I found the following in the help:

Dim obj As Object
Set obj = Application.CurrentProject

If obj.AllForms.Item(&quot;<form_name>&quot;).IsLoaded Then
...
End If
 
The &quot;Isloaded&quot; function above is as follows.



Function IsLoaded(ByVal strFormName As String) As Integer
' returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

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

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top