How do I check if a hidden form is open/loaded?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I check if a Hidden form is open/loaded using code?
I've got a menu form that opens 5 reports and as it does this, a hidden form
unhides to to give the user a reminder. On this reminder form there is a
"Don't Show me this screen again" check box that closes the form rather than
hiding it when it's 'OnDeactivate' event runs.

My problem is that when the form is closed rather than hidden, my reports
don't open and I get a message that says the now closed form can not be
found.
I want to put in a little bit of code that checks if the reminder form is
closed and not just hidden and if it is closed then to not try to unhide it.

Do I use the "IsLoaded" function and if so has anyone got any examples that
aren't to difficult to follow?!

If anyone can help I'll be very, very happy camper.
 
Dim objForm As AccessObject

Set objForm = CurrentProject.AllForms("Your Popup Form Name")
If objForm.IsLoaded = True Then
MsgBox "It is loaded"
Else
MsgBox "It isn't loaded"
End If
 
Great example. Thank you for your help.


Dennis said:
Dim objForm As AccessObject

Set objForm = CurrentProject.AllForms("Your Popup Form Name")
If objForm.IsLoaded = True Then
MsgBox "It is loaded"
Else
MsgBox "It isn't loaded"
End If
 
I don't recall where I got this (might be from Northwind, or from
www.mvps.org/access), but here is a function that I use:

Public Function IsTheFormOpen(ByVal xstrFormName As String) As Boolean
'Returns False if form is not open or is open in design view; returns
' True if it is open in form or datasheet view
On Error Resume Next
' Set default value for the function
IsTheFormOpen = False
If SysCmd(acSysCmdGetObjectState, acForm, xstrFormName) <> 0 Then
If Forms(xstrFormName).CurrentView <> 0 Then IsTheFormOpen = True
End If
End Function
 
Back
Top