Check if Form is Open

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
 
S

Stuart McCall

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top