IsLoaded

P

paul

I have the following code to determine if a form is loaded. I would like to
use it to find out if a "SUBFORM" is loaded. I tried it and it will not
work. Please would someone advice me how to edit this code to work with the
subform. Thanks.

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet
view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
 
D

Dirk Goldgar

paul said:
I have the following code to determine if a form is loaded. I would
like to use it to find out if a "SUBFORM" is loaded. I tried it and
it will not work. Please would someone advice me how to edit this
code to work with the subform. Thanks.

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or
Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

This code cannot be adapted to tell if a subform is loaded, because a
subform is not "loaded" in the same way that a form is loaded.
Similarly, a subform is not a member of the Forms collection (which
contains all open forms), so you can't search for it there.
Furthermore, there could be multiple instances of the same form object
appearing in several different subform controls at the same time.

It would be possible to search every open form for any subform controls,
and then check each subform control's SourceObject to see if it is the
name of the subform you're looking for, and if those subforms have
subform controls search each of *them*, and so on. But is it worth it
for what you want to do? Could you explain in broader terms what you're
trying to accomplish?
 

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

Similar Threads

Module mystery 2
HELP 6
Function Name problem 5
Problem checking if form is open 2
Subform Activation 0
Return without GoSub? 3
Access 97 Module Code 2
On Close () 0

Top