Check if Form is Open

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

I need to check to see if a form is open in the Onclose of another form.
And if it is to requery it, if not do nothing. I did find a Function on
The Access Web web site but I'm not sure how to utilize the function.

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function

I need to run this in the OnClose of a form to see if frmHome is open. I
know
I need to pass the form name in the Function Arguments but not sure of
things after that.
Can someone please enlighten me?

James
 
JamesJ said:
I need to check to see if a form is open in the Onclose of another form.
And if it is to requery it, if not do nothing. I did find a Function on
The Access Web web site but I'm not sure how to utilize the function.

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function

I need to run this in the OnClose of a form to see if frmHome is open. I
know
I need to pass the form name in the Function Arguments but not sure of
things after that.
Can someone please enlighten me?

James

If fIsLoaded("frmHome") Then
Forms!frmHome.ReQuery
End If
 
Back
Top