Exit Access - Execute code

G

Guest

Greetings!

My app can execute code if the user exits via the EXIT button I provide on
various forms.

However, if the user clicks the X on the top right of the window, that code
is not peformed. Is there an event that fires when that X is clicked and is
there a way to capture that event so I can execute some code during the
close/exit process?
 
G

Guest

If you have a main menu that's always open, use that Form's On Close event.
That should get triggered whenever they close the appl. Otherwise the only
way I know of would be to code an On CLose event proc for each form. I don't
know of any way to trigger a procedure on the close of the appl, but some of
the more knowledgable folks here may know of a way to do that (something
along the lines of the AutoExec macro that gets executed on startup).
 
A

Albert D. Kallal

The on close event of the form still runs. so, code that needs to run when a
user closes a form can be execution in the on-close event.

In fact, when possible, you want all code that runs when a form closes in
that event, as then it don't matter if you have several places that executes
a docmd.close, or the user clicks on the "x" in the upper right hand of the
form.

for a application close event, often developers just open up a form, and
then make it invisible...when you close the application, .that forms close
event will run..and thus you have a application close event.....
 
K

Keith Wilby

Bob Bonta said:
Greetings!

My app can execute code if the user exits via the EXIT button I provide on
various forms.

However, if the user clicks the X on the top right of the window, that
code
is not peformed. Is there an event that fires when that X is clicked and
is
there a way to capture that event so I can execute some code during the
close/exit process?

Set your form's popup and modal properties to "Yes" and put your code in the
Unload event.

HTH - Keith.
www.keithwilby.com
 
G

Guest

Thanx ... Jim and Al ... the solution was extremely simple. I hadn't thought
of that and since the main form is always open, I simply moved my code from
the cmdExit event to the Form's OnClose event.

Keith, I appreciate your suggestion but since I have other popup/modal forms
called by buttons on my main form, the subsequent forms would not be
permitted to click on any fields/buttons. But, as I said, I moved the code
to the OnClose event which is launched by either the cmdExit button or by
clicking the X on the Access window.

Thanx all! Always great support here ...
 
K

Keith Wilby

Bob Bonta said:
Keith, I appreciate your suggestion but since I have other popup/modal
forms
called by buttons on my main form, the subsequent forms would not be
permitted to click on any fields/buttons.

That's not strictly true. I always organise my forms into hierarchical
layers so I've never had that problem.

Regards,
Keith.
 

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