Recording user log-ins

Charlottew14

Registered User.
Local time
Today, 09:07
Joined
Oct 4, 2012
Messages
32
Hi,

I'm a bit of an access novice, and I'm not good at all with coding, so please bear with me!

I have a database, with a user login, and that takes you to a "menu" where you can choose to enter, change user or exit. Users would then press enter to go to their home page, determined by what type of user they are.

I'm looking to record the time and date of each time a user logs in, and then the time and date they press "exit through the menu screen.

Any tips?

Much appreciated!!
 
You'll need a new table with; UserID, a date/time field and an In/Out field. Make the date field's default value =Now(). The In/Out field could be a 3 digit text field.

strSQL = "INSERT INTO tblUserLog ( UserID, InOut )"
strSQL = strSQL & " VALUES ( " & [TempVars]![CurrentUserID] & ", 'In' ); "

DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

You'd swap the "in" for "out" on the logout click.

This assumes you've set a new temp var for the user ID. You may want to get the value from the combo or list box on your login form.

" & Me.[lbxUserID] & "

You might need to tweak the SQL as I haven't tested it and I'm new to this too! :)
 
Last edited:
Thanks for your reply, but that sounds far beyond my capabilities!!!

I've been trying to do in a simpler way - though much less sophisticated - by having a hidden form opening at the same time as the menu screen to record the login time, pulling the username from the menu. However, I can seem to get this to work either as it won't save the record using macros or vba!
 
Hi,

I like that method, but I'd prefer that the user didn't see the information captured, especially about other people that have logged in and out.

I've attached a sample of my database, so you can see how the login/menu screens work (username: test & password: test).

Ideally, I'd like to record the "in" when enter in pressed on the menu, and the "out" when quit is pressed.

Any ideas if this is even possible?

Thank you so much for your help :)
 

Attachments

I just put the list box in there to show it was working. Must dash, there is lunch to be had.
 
You'd want to insert the "INSERT INTO" SQL string after the erm....

If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") Then
strUser = Me.cboUser.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") 'set the value of strRole declared as Global Variable
DoCmd.Close acForm, "frmLogin", acSaveNo
MsgBox "Welcome Back, " & strUser, vbOKOnly, "Welcome"
DoCmd.OpenForm "frmMenu", acNormal, "", "", , acNormal
HERE

Else
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
intLogAttempt = intLogAttempt + 1
txtPassword.SetFocus
 

Users who are viewing this thread

Back
Top Bottom