In Need of an If statement

yeatmanj

Loose Cannon
Local time
Today, 17:49
Joined
Oct 11, 2000
Messages
195
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

IsLoaded = blnSuccess
End Function
 
here is something in use below. It may help also.

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.

isOpen = (SysCmd(acSysCmdGetObjectState, intObjectType, strName) <> 0)

norm

[This message has been edited by norm (edited 10-19-2000).]
 
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.

I do appreciate your help though. Thank You.
 

Users who are viewing this thread

Back
Top Bottom