Users in DB? (1 Viewer)

bigal.nz

Registered User.
Local time
Today, 21:52
Joined
Jul 10, 2016
Messages
92
Hi,

I found a great way to get the current User ID and User Name for the currently logged on user and write to a table so I can keep a record of other users in the database.

But how do I mark a user as having left the database - what is the triggering event?

Cheers

-Al
 

Isskint

Slowly Developing
Local time
Today, 10:52
Joined
Apr 25, 2012
Messages
1,302
hi bigal

If you have one form that is always open (a menu form?), the easiest way is to use the OnClose event of a form to update the log. If you use a button to close the database, add the code there.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:52
Joined
Feb 28, 2001
Messages
27,194
BigAl, just remember that a problem comes about if the network goes down, because in that case your user will not log out - because they won't have a chance before the connection crashes. So remember that "out" date/times are not always going to be there. Also, if the user does something really ugly from, say, Task Manager, they might be able to make Access exit without finishing that logout process.

I take the approach of looking at their terminal. There is no reason in my database for a single user to have two independent sessions from the same terminal under the same user account, so if the Environ("COMPUTERNAME") and Environ("USERNAME") match a prior entry that I think is still open, I close it with an event log showing that I killed a dangling session. Of course, if you don't use those two Environ calls, you might not have such an easy time of determining that case, but I'll say this: It works most of the time for me.
 

speakers_86

Registered User.
Local time
Today, 05:52
Joined
May 17, 2007
Messages
1,919
I've seen a sample that is able to read the backend's record locking file and tell who is using it. Would it help if I linked to it? I'm not sure if this is okay to do though...
 

bigal.nz

Registered User.
Local time
Today, 21:52
Joined
Jul 10, 2016
Messages
92
Thanks for the replies guys.

Yes it is a mainform.

If the user ungracefully exists Access (Im thinking those who just click the cross to exit access) will it still trigger the form unload event?

Cheers

-Al
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:52
Joined
Feb 28, 2001
Messages
27,194
Yes, Form_Unload triggers if you are trying to exit the application. (Or at least it triggers in my DB that has a permanently open switchboard).
 

Users who are viewing this thread

Top Bottom