I know there's a Startup form, but what about a "Close" form?

  • Thread starter Thread starter JShrimps, Jr.
  • Start date Start date
J

JShrimps, Jr.

I need a query to run every time a person exists the database.
This query does some cleanup to data left in an unfinished state.
I'm using a form at startup that is opens in hidden mode.
When the database is closed (and thus closing this hidden form),
the form has a docmd.openquery in
the form_close event
which updates the unifished business.
Doesn't really work that well.

Is there a way to run a query every time a database is closed?
 
JShrimps said:
I need a query to run every time a person exists the database.
This query does some cleanup to data left in an unfinished state.
I'm using a form at startup that is opens in hidden mode.
When the database is closed (and thus closing this hidden form),
the form has a docmd.openquery in
the form_close event
which updates the unifished business.
Doesn't really work that well.

Is there a way to run a query every time a database is closed?

What you describe is the standard technique for this sort of thing, as
far as I know. In what way does it "not really work that well"? Maybe
we can think of a way to address the specific problems.
 
I need a query to run every time a person exists the database.
This query does some cleanup to data left in an unfinished state.
I'm using a form at startup that is opens in hidden mode.
When the database is closed (and thus closing this hidden form),
the form has a docmd.openquery in
the form_close event
which updates the unifished business.
Doesn't really work that well.

How about doing the cleanup when they exit the form where the unfinished
business takes place, or to stop them exiting the database before it
happens, disable the 'X' close buttons on each and every form...forcing them
to exit clean by means of a menu or similar......

just a thought...
Pete
 
To answer Dirk's question specifically - which I left out
in the first post to try to be brief - if you have a query
run on the form_close event, when the database closes
and the form, which has been open the whole time,
is closed by the database, you get a message prompting you
for any variables contained in the query. (The query is question
is an update query, requriting a bit of info from the form that
was closed by the database).

To make an even longer story longer, the form in question contains
the logon ID of the person who has opened the database. The User's
ID is appened to a table each time they open the database. I would
like to also record the time of exit - matching an exit time for every
entry time
in the database (that's what the query does, adding Now() to every null
exit date/time for that User's login ID).

Table is very simple, layout looks like this.
Entry Entry Logout Logout
login Date Time Date Time

bgates 12/1/03 8:45 am 12/1/03 12:25 pm
RHoward 12/2/03 12:15pm 12/2/03 4:45 pm

you get the idea...
Sorry for being so obtuse....
 
JShrimps said:
To answer Dirk's question specifically - which I left out
in the first post to try to be brief - if you have a query
run on the form_close event, when the database closes
and the form, which has been open the whole time,
is closed by the database, you get a message prompting you
for any variables contained in the query. (The query is question
is an update query, requriting a bit of info from the form that
was closed by the database).

To make an even longer story longer, the form in question contains
the logon ID of the person who has opened the database. The User's
ID is appened to a table each time they open the database. I would
like to also record the time of exit - matching an exit time for
every entry time
in the database (that's what the query does, adding Now() to every
null exit date/time for that User's login ID).

Table is very simple, layout looks like this.
Entry Entry Logout Logout
login Date Time Date Time

bgates 12/1/03 8:45 am 12/1/03 12:25 pm
RHoward 12/2/03 12:15pm 12/2/03 4:45 pm

you get the idea...
Sorry for being so obtuse....

So the query is referring to controls on the form? What happens if you
use the form's Unload event instead of the Close event? Since that
event is cancellable, I'd expect any controls on the form to retain
their values until after the event is complete.
 
Back
Top