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 strongm 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

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
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.
 
It is probably easiest to look through the Forms collection which will contain all the active forms.

Dim fm As Form
For Each fm In Forms
Debug.Print "Form name = "; fm.Name
if fm.name = "myform" then
do something
end if
Next
 
Try The below in a mocule.
Cortesy of frmsmp00.mdb

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