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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Isloaded error 1

Status
Not open for further replies.

Vcscwi

Programmer
Jan 15, 2004
57
US

I have a form that when a user wants to add to the subform they press a button which opens a an "add" form to enter the new data. When the user is done and is closing the "add" form, I want to check if I need to requery the subform...but I'm gettiing an error.

Here is the code for the "Add" form OnClose

If CurrentProject.AllDataAccessPages("forms!clientform").IsLoaded = True Then
Forms!ClientForm![Medical Ins Sub Form].Requery
End If



My error highlights my IsLoaded line and reads.
Run-time Error '2467'
The expression you entered refers to an object that is closed or doesn't exist.

I know this is not the case and must be a coding error on my part... does anyone see what's wrong?

Thanks
 
Use only the form name:

[tt]If CurrentProject.AllDataAccessPages("clientform").IsLoaded ...[/tt]

But aren't you supposed to use the AllForms collection for forms?

Roy-Vidar
 
Hmmm. I tried your code change and I still get the same error. I'm not quite sure what you mean regarding AllForms. I'm testing if a form is open from a form....

Am I just missing something?
 
But you are using the AllDataAccessPages collection, not the AllForms collection.

Also, to reach the subform, you'll probably need to use

[tt]Forms!ClientForm![Medical Ins Sub Form].Form.Requery[/tt]

- if that's the correct subform control name (which can differ from the subform name as viewed in the database window). To find the correct subform control name, invoke the expression builder, doubleclick through forms, loaded forms, main form, subform and a control on the subform. This should give the correct reference, where you can just strip of the controlname.

Roy-Vidar
 
Thanks! That did it.

If CurrentProject.AllForms("clientform").IsLoaded ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top