By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

One last command before DB closes

P: n/a
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the 'Logged_out'
time and then quits the application. My problem is that when users click on
the cross (top right corner) to close the database, this time is not logged.

Is there a way in which I can still log the time even when they click on the
application close button or a way in which I can hide the close button so
that the only way the application can be shut down is via my close button?

TIA

Mark
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
One common approach to this problem is to have a small form (its visible
property can even be set to False) which opens on startup and remains open
throughout the time the application is open. Closing Access causes this
form to close, so code in its Close event executes. Put your "logout" code
there.

HTH
- Turtle

"Mark R" <ma*********@ntlworld.com> wrote in message
news:XH**************@newsfe2-gui.ntli.net...
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the 'Logged_out' time and then quits the application. My problem is that when users click on the cross (top right corner) to close the database, this time is not logged.
Is there a way in which I can still log the time even when they click on the application close button or a way in which I can hide the close button so
that the only way the application can be shut down is via my close button?

TIA

Mark

Nov 13 '05 #2

P: n/a
"Mark R" <ma*********@ntlworld.com> wrote in message news:<XH**************@newsfe2-gui.ntli.net>...
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the 'Logged_out'
time and then quits the application. My problem is that when users click on
the cross (top right corner) to close the database, this time is not logged.

Is there a way in which I can still log the time even when they click on the
application close button or a way in which I can hide the close button so
that the only way the application can be shut down is via my close button?

TIA

Mark

Lemme see if I remember the answer to this one.... open a hidden form
when the database starts up, and then have it write to the Logins
table. Then when the user logs out, grab his login from today, update
it with the logout, and update the record in the Form's close event.
Nov 13 '05 #3

P: n/a
Use the Unload event in Access...

http://msdn.microsoft.com/library/de...cevtUnload.asp

I created a blank database, added a "close" button and a displayed a
message saying that button was clicked. I also tossed a message box
into the Form Unload event saying the form is being unloaded. When
you click the button both message boxes show up... when you close the
database (by clicking the X or Cross not the button on the form) it
just displays the unload event message box.

- Craig

"Mark R" <ma*********@ntlworld.com> wrote in message news:<XH**************@newsfe2-gui.ntli.net>...
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the 'Logged_out'
time and then quits the application. My problem is that when users click on
the cross (top right corner) to close the database, this time is not logged.

Is there a way in which I can still log the time even when they click on the
application close button or a way in which I can hide the close button so
that the only way the application can be shut down is via my close button?

TIA

Mark

Nov 13 '05 #4

P: n/a
Thanks for the suggestion, however, The main form is open all the time and
the "logout" code is in the "OnClose" property of this form. The problem I
have is when the Db is opened, the user sees a login form. The user then
enters their login and password. When they click on a command button the
username is appended to a temp table within the frontend and in the logging
table within the backend (along with date/time opened).
As there may be several users at any time, the time logged out needs to be
reference with the current user. This is done by having a bound text box on
the main form to the temp table within the frontend. The "OnClose" command
is:
Private Sub Form_Close()
'record the time at which users logged out
On Error GoTo err_form_close

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE user_logging SET user_logging.Out = Now() WHERE
(((user_logging.Out) Is Null) AND ((user_logging.Form)='Main Menu') AND
((user_logging.username)= forms!master_page!userid));"

'delete the current user field
DoCmd.RunSQL "delete * from current_user;"

exit_form_close:
Exit Sub

err_form_close:
MsgBox Err.Description
Resume exit_form_close
End Sub

If the form is closed before the app is quit then there is not problem but
if the app is quit before the form is closed, the form loses the value and
then the user id prompted for forms!master_page!userid.

I hope I have explained this ok?

Mark

"MacDermott" <ma********@nospam.com> wrote in message
news:zC*******************@newsread2.news.atl.eart hlink.net...
One common approach to this problem is to have a small form (its visible
property can even be set to False) which opens on startup and remains open
throughout the time the application is open. Closing Access causes this
form to close, so code in its Close event executes. Put your "logout" code there.

HTH
- Turtle

"Mark R" <ma*********@ntlworld.com> wrote in message
news:XH**************@newsfe2-gui.ntli.net...
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the

'Logged_out'
time and then quits the application. My problem is that when users click

on
the cross (top right corner) to close the database, this time is not

logged.

Is there a way in which I can still log the time even when they click on

the
application close button or a way in which I can hide the close button so that the only way the application can be shut down is via my close button?
TIA

Mark


Nov 13 '05 #5

P: n/a
Two possibilities you might try:
Use the Form_Unload event, rather than Form_Close.
Store the UserName in a global variable, rather than a textbox on the
form.

HTH
- Turtle

"Mark R" <ma*********@ntlworld.com> wrote in message
news:yf***************@newsfe6-gui.ntli.net...
Thanks for the suggestion, however, The main form is open all the time and
the "logout" code is in the "OnClose" property of this form. The problem I
have is when the Db is opened, the user sees a login form. The user then
enters their login and password. When they click on a command button the
username is appended to a temp table within the frontend and in the logging table within the backend (along with date/time opened).
As there may be several users at any time, the time logged out needs to be
reference with the current user. This is done by having a bound text box on the main form to the temp table within the frontend. The "OnClose" command
is:
Private Sub Form_Close()
'record the time at which users logged out
On Error GoTo err_form_close

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE user_logging SET user_logging.Out = Now() WHERE
(((user_logging.Out) Is Null) AND ((user_logging.Form)='Main Menu') AND
((user_logging.username)= forms!master_page!userid));"

'delete the current user field
DoCmd.RunSQL "delete * from current_user;"

exit_form_close:
Exit Sub

err_form_close:
MsgBox Err.Description
Resume exit_form_close
End Sub

If the form is closed before the app is quit then there is not problem but
if the app is quit before the form is closed, the form loses the value and
then the user id prompted for forms!master_page!userid.

I hope I have explained this ok?

Mark

"MacDermott" <ma********@nospam.com> wrote in message
news:zC*******************@newsread2.news.atl.eart hlink.net...
One common approach to this problem is to have a small form (its visible
property can even be set to False) which opens on startup and remains open
throughout the time the application is open. Closing Access causes this
form to close, so code in its Close event executes. Put your "logout"

code
there.

HTH
- Turtle

"Mark R" <ma*********@ntlworld.com> wrote in message
news:XH**************@newsfe2-gui.ntli.net...
Hi Guru's,
I have a frontend application where my boss wants to when people are using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the

'Logged_out'
time and then quits the application. My problem is that when users
click on
the cross (top right corner) to close the database, this time is not

logged.

Is there a way in which I can still log the time even when they click
on the
application close button or a way in which I can hide the close button

so that the only way the application can be shut down is via my close button?
TIA

Mark



Nov 13 '05 #6

P: n/a
Thanks all, I moved the code to OnUnload and it works fine.

Cheers all,

Mark

"Mark R" <ma*********@ntlworld.com> wrote in message
news:XH**************@newsfe2-gui.ntli.net...
Hi Guru's,
I have a frontend application where my boss wants to when people are
using the database.
I have a form which OnOpen, inserts the username, network login and
date/time it was opened to a table.
I have created a 'Close' button which when clicked, updates the 'Logged_out' time and then quits the application. My problem is that when users click on the cross (top right corner) to close the database, this time is not logged.
Is there a way in which I can still log the time even when they click on the application close button or a way in which I can hide the close button so
that the only way the application can be shut down is via my close button?

TIA

Mark

Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.