I need an "If" statement that checks to see if a form is open, so that if it isn't a portion of the code won't run. I saw it the other day when looking through help files, and i'm embaraced to say i can't find it now.
Call this code, passing in the name of the form that you want to check ...
' Checks to see if a specific form is currently loaded or not
' and returns TRUE if so, FALSE if not.
Public Function IsLoaded(strFormName As String) As Boolean
Dim frmForm
Dim blnSuccess As Boolean ' this becomes "true" if the form is found
On Error Resume Next
For Each frmForm In Forms
If frmForm.NAME = strFormName Then
blnSuccess = True
End If
Next
Function isOpen(strName As String, Optional intObjectType As Integer = acForm)
'Returns True if strName is open, False otherwise.
'Assume the caller wants to know about a form.
I appreciate your input. I posted the topic and kept searching through the help files. What I wanted turned out to be an on error. I was using code that ran a requery on a form, but the form had to be open for the requery to work. I was essentially using the same form in two places and when you clicked save it would try to requery the main form. The second place went around the main form, so i needed an on error statment so the requery could be skipped.