quiting access through quit() brings errors with unset objects

M

mo adesnik

I have a bunch of forms running ,and these forms set up
various user-defined class objects.
the trouble occurs when i choose a menu item which calls a
function which prompts the user to confirm and then use
the docmd.quit command in a macro to exit. (i use the
acSaveNone option.)
when I do this the infamous error "object not set or
initialized" occurs in the form_beforeUpdate() of one of
my forms or in the form_unload() of another. those events
refer to user defined objects and now Access says they are
undefined.
however, clicking the regular exit item from the file menu
works fine.
it seems like Access is erasing my objects and then trying
to call them? that shouldn't happen though?
if anyone thinks they know what's going on, i could use
the help.
Mo
 
M

Marshall Barton

mo said:
I have a bunch of forms running ,and these forms set up
various user-defined class objects.
the trouble occurs when i choose a menu item which calls a
function which prompts the user to confirm and then use
the docmd.quit command in a macro to exit. (i use the
acSaveNone option.)
when I do this the infamous error "object not set or
initialized" occurs in the form_beforeUpdate() of one of
my forms or in the form_unload() of another. those events
refer to user defined objects and now Access says they are
undefined.
however, clicking the regular exit item from the file menu
works fine.
it seems like Access is erasing my objects and then trying
to call them? that shouldn't happen though?
if anyone thinks they know what's going on, i could use
the help.

Not sure I know what I'm doing, but I have run into that
problem before.

You're right, Access just destructs your classes as soon as
you use the Quit method. (I don't remember if it invokes
each class's Terminate method, but it doesn't really matter
since it would be too soon anyway.) The way I got around
this issue is to create a shutdown sub procedure that closes
all open forms and reports (which supposedly will terminate
the classes) and, only after everything is squared away, the
procedure then performs the Quit method.

Not pretty, but, at least in my case, doable.
 

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