Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking users

Status
Not open for further replies.
Sep 12, 2007
45
US

I am working on a way to track users who log in and out of 6 Access databases (front end) in different locations (network drives) into a table in an exclusive database with details (fields) such as ConnectionID; Username; User Computer name; database name; date/time logged in; date/time logged out.

I have placed an append query on the OnLoad property of the First form that opens in each database (which is never closes as long as the Access database front end is up and running). This First form is different in different database front ends i.e. it can be the welcome form or the menu form or a form displaying the title/name of the database). The append query inserts the ConnectionID (incremental based on previous maximum value); Username; User Computer name; database name; and date/time logged in.

I have placed an update query on the OnClose property of the first form. The update query updates the date/time logged out for the ConnectionID based on the user’s Username.

This setup is working as intended but I wanted to know if there was a function that can be used which would eliminate the need to place queries on the OnLoad and OnClose properties of the form.

I have found and functions for Username; User Computer name; and database name on the internet which are used as criteria for these fields in the queries but don’t know how I can achieve this process without using individual (first open) forms in different databases.

Thank you.
 
A more generic startup way would be to run an autoezec macro (autoexec runs at startuo). Although only a form is going to give you a quit event.

It seems like what you really want is a common way of doing things. There is no reason you can't have two forms open in the background.
 
Hi,

As Iameid mentioned, you can use the autoexec macro to run your Update Query on log in, and if you've already got a menu for the users, add an Exit button to it. The Exit button could run a macro containing the Update Query to indicate the user has left the app. As long as the users use the button to exit the app, it works very well. I've had this running for the last 17 years and it works like a charm.

Hope this helps!
 
Lameid and Meagain, thank you for your suggestions.

My main issue is with how the users close the Access database. Append query in the Autoexec works perfectly as there is pretty much only one way of opening the accdb file. I have exit command buttons on all the forms and have disabled the close (x) button on all of them. Ideally, most users use the exit button to close the database but quite a few close the database by clicking on the close button of the application (top right corner). When this is done, the update query fails to run and there is no log out time entry created.

I looked up disabling the application close button and found this solution online ( but the caveat in the solution warns that there is a possibility that users might not be able to close the database properly and "get stuck in an infinite loop or dead-end". It asks for creating proper error handling methods to avoid this situation but I am not sure what kinds of errors will be generated or not generated frustrating the users to go through the task manager to close the database.

Basically, I was looking for something like an Autoexec for closing of the database which would run the update query consistently and reliably regardless of how the user closes the accdb file. It would really help if there is a way to ensure the closing of the main/first form which initiates the update query can be forced to work with the closing of the accdb file.

Again thank you both for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top