Dynamic logged-in user table

stevekos07

Registered User.
Local time
Yesterday, 17:28
Joined
Jul 26, 2015
Messages
174
I am trying to set up a dynamic logged-in user table where I can keep tabs on who is logged in to a database. I have some of the system working, but the last bit is not working for me.

Currently I have:

a "frmLogin" with txtUserName and a txtUserID fields. The AfterUpdate event on the txtUserName creates a temporary variable tmpUser.

The OK button runs a script that does all the checking of their username, password etc. and this works fine.

At the end of all this the last line is a command to open a hidden form frmUserLoginHidden, with two text boxes - txtUserName and txtUserID.

The OnOpen event of the hidden form sets the value of txtUserName as the temp variable tmpUser. This works ok.

I can then view the logged in user in the table/form ok. This part works fine.

Then I have a delete query that is called on the OnClose event of the hidden form. This is the SQL:

DELETE tblLoggedOnUser.DateTime, tblLoggedOnUser.UserName
FROM tblLoggedOnUser
WHERE (((tblLoggedOnUser.UserName)=[Forms]![frmUserLoginHidden]![UserName]));


My understanding is that all I need is one field identified in the record to delete the entire record with a delete query, but I have identified two.

This delete query fails to delete the record in the tblLoggedOnUser.

Any ideas?
 
you just need *

DELETE * FROM .....

but you may not be able to delete it if the record is open in your logged in form.
 
you just need *

DELETE * FROM .....

but you may not be able to delete it if the record is open in your logged in form.

Thanks. But I found the problem. I was referencing the field in the hidden form as UserName rather than txtUserName.

The silly things we miss!!
 
Stevekos07,

You should be aware that this is actually harder than you might think. Users sometimes don't log off properly and your code to register the logout event, no matter HOW you actually try to do it, sometimes doesn't get run.

For instance, if your network has an idle-time enforcer, it can kill your session in a way that prevents the logout entry from occurring. Or if your user logs out by pressing the power button (and sadly, there ARE those who do that...), you just lost that event as well. Login/out records are really useful but DAMN they can get tricky sometimes.
 
Also, I wouldn't delete the login record, I would add a logout record. Then you can start to develop stats, using ALL the saved logins and logouts to better understand how and when users are using the program.
 
Concur with MarkK - easier to log the event and not leave a record dangling while waiting for a logout event that might never come.
 
Concur with MarkK - easier to log the event and not leave a record dangling while waiting for a logout event that might never come.

Yes, you might be right about that. But this project was more for my own convenience than an operational imperative. It is working fine, even though there have been some unexplained non-recorded logouts. The logins are correct, and that's the main reason I put it together. It at least gives me an idea of who is logged on, and the time, so that I have a list of potential users to email to ask to logout if I need to do some maintenance on the tables.

When I have some spare development time (:rolleyes:) I will play with developing two separate tables.
 

Users who are viewing this thread

Back
Top Bottom