Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isloaded("zfrmName") returns false on active subform 1

Status
Not open for further replies.

JEShannon

Programmer
Oct 25, 2002
8
0
0
US
I have a tabbed form with multiple linked sub-forms visible, linked and working.

With this form running and populated I go to the "Immediate Window" and type:
?isloaded("zfrmCRMNotes") {which uses: SysCmd(acSysCmdGetObjectState, acForm, FormName)}
False <is returned>

I get the same results when I step through the forms collection whether I use:
If obj.IsLoaded = True
If frm.Name = strFormName

Can it be that running subforms are not considered isloaded=true?

The reason I need this even though the form works fine is that on first load of a parent form (before the subform is loaded) I'm getting:
&quot;You entered an expression that has an invalid reference to the property Form/Report.&quot;
on the line:
Forms![frmOrderStatus]![zfrmCRM].Form![zfrmCRMNotes].Form![ONote] = Nz(rst!OCmt, &quot;&quot;)

My solution is to preface poking data into this subform fields with:
If not isloaded(&quot;zfrmCRMNotes&quot;) then exit sub.

But this test always fails (even when the subform IS open).

How can I avoid the initial error when it truly isn't loaded yet not be blocked when it is loaded?

Jim
 
You don't have to check if the form is loaded. If you just want to ignore the error you can put On Error Resume Next before you set the value on the subform. So you will have:

On Error Resume Next

Forms![frmOrderStatus]![zfrmCRM].Form![zfrmCRMNotes].Form![ONote] = Nz(rst!OCmt, &quot;&quot;)


If you have other code in the Load event then you may want to set up an error handler to catch other errors and only ignore the one you are currently getting.

Hope this helps






 
Thanks ITMannie!.

That was my solution to the main problem (unsitely error messages worrying the user) too, but it skips the first part of the question:
Can it be that running subforms are not considered isloaded=true?
and the implied question:
How can you check programatically whether a certain form is loaded when it is a subform?

Any ideas?

Jim
 
Access doesn't provide a way to determine if a subform is loaded. But, since the subform(s) actually open and load before the form you may take advantage of this info to set up a global variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top