So have created a database, and now I need a way to track who logs in. I have a tblLogInTracker with the following info on it.
LoginTrackerID
Username
Login Time
Login Date
When I press the 'Login' button on the login screen this is the code that I have:
How do I get this to track who logs in with the user name and place it with the time and date into the tblLogInTracker?
I'm new to VBA :/
LoginTrackerID
Username
Login Time
Login Date
When I press the 'Login' button on the login screen this is the code that I have:
Code:
Private Sub btnLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tblUser", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "Username='" & Me.txtUsername & "'"
If rs.NoMatch = True Then
Me.lblWrongUser.Visible = True
Me.txtUsername.SetFocus
Exit Sub
End If
Me.lblWrongUser.Visible = False
If rs!Password <> Nz(Me.txtPassword, "") Then
Me.lblWrongPass.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblWrongPass.Visible = False
If rs!AccessCode = 3 Then
Dim prop As Property
On Error GoTo SetProperty
Set prop = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False)
CurrentDb.Properties.Append prop
SetProperty:
If MsgBox("Would you like to turn on bypass key?", vbYesNo, "Allow Bypass") = vbYes Then
CurrentDb.Properties("AllowBypassKey") = True
Else
CurrentDb.Properties("AllowBypassKey") = False
End If
End If
' The following code determines where the user will go based on their access code
Select Case rs!AccessCode
Case Is = 3
MsgBox "You are entering Development Mode."
DoCmd.OpenForm "frmDeveloperNavigation"
Case Is = 2
MsgBox "You are entering Admin Mode. If you have any problems please contact the development team at wdhodges@carilionclinic.org"
DoCmd.OpenForm "frmAdminNavigation"
Case Is = 1
DoCmd.OpenForm "frmNavigation"
Case Else
MsgBox "You do not have access to view this database. If you would like access please email: wdhodges@carilionclinic.org"
End Select
' End access user sorting
DoCmd.Close acForm, Me.Name
How do I get this to track who logs in with the user name and place it with the time and date into the tblLogInTracker?
I'm new to VBA :/