BlueStarBrite
Registered User.
- Local time
- Today, 15:49
- Joined
- Jan 15, 2009
- Messages
- 23
Ok, so I have a login form in which has username and password fields. I am wanting to collect the logintime and the logout time for each user. Initially before I added the password code field, it was tracking the login/logout just fine. However, now its not. I am not sure where I went wrong and am starting to spin my wheels.
Please help! Thanks in advance.
Here is my code for my LogIn Button:
Here is my code for my LogIn Button:
Code:
Private Sub cmdLogIn_Click()
On Error GoTo Err_cmdLogIn_Click
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblLogTimes", dbOpenDynaset)
If IsNull(Me.Combo0) Then
MsgBox "You must select a username!", vbInformation, "Required Data"
Me.Combo0.SetFocus
Exit Sub
'Else
End If
'Check to seeif data is entered into the passwordbox
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password!", vbInformation, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblNames to see if this matches necessary value chosen in combobox
If Me.txtPassword.Value = DLookup("Password", "tblNames", "[ClientId]=" & Me.Combo0.Value) Then
lngMyEmpId = Me.Combo0.Value
'Open switchboard main menu
DoCmd.OpenForm "Switchboard"
Else
MsgBox "Password Invalid. Please Try Again!", vbInformation, "Invalid Entry"
With rst
.AddNew
![ClientID] = Me.Combo0
.Update
.Close
End With
MsgBox "Log In Successful"
End If
'If User Enters incorrect password 3 times, database will shut down
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have proper access to this database. Please contact your system administratior.", vbCritical, "Restricted Access!"
Application.Quit
End If
Exit_cmdLogIn_Click:
Exit Sub
Err_cmdLogIn_Click:
MsgBox Err.Description, , " db1"
Resume Exit_cmdLogIn_Click
End Sub