can't unload a form

G

Guest

This statement

Unload Forms(strStats)

causes Error 361: "Can't load or unload this object". Both a form and a
query with the name strStats exist; only the form is open when the code tried
to close it. 'Help' does not seem to address my problem. Is there anything
else i can look for?

Thanks!
 
K

Keith Wilby

Allen_N said:
This statement

Unload Forms(strStats)

causes Error 361: "Can't load or unload this object". Both a form and a
query with the name strStats exist; only the form is open when the code
tried
to close it. 'Help' does not seem to address my problem. Is there anything
else i can look for?

Thanks!

Have you tried renaming the query? As a rule of thumb, many developers use
meaningful prefixes such as "frm" for form and "qry" for query. "str" would
suggest string variable.

Regards,
Keith.
www.keithwilby.com
 
D

Dirk Goldgar

Allen_N said:
This statement

Unload Forms(strStats)

causes Error 361: "Can't load or unload this object". Both a form and
a query with the name strStats exist; only the form is open when the
code tried to close it. 'Help' does not seem to address my problem.
Is there anything else i can look for?

You don't unload Access forms that way. Use

DoCmd.Close acForm, "strStats"

if "strStats" is the actual name of the form, or

DoCmd.Close acForm, strStats

if strStats is a string variable containing the name of the form.
 
G

Guest

Thanks, Dirk.

I should have figured that out for myself, given that "Load
Forms(strFormName)" doesn't work either. Moving from VB to VBA is fraught
with peril.
 
G

Guest

Thanks Keith.

I followed Dirk's advice. Re: your suggestion, I use the "frm" prefix for a
form object, and "str" for a string that holds the form name. I'm starting to
use the suffix "Form" in the latter, to minimise confusion as my project
grows.
 

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