Code does not work according to first line.... my database is having problems witht the first line of my code.... which is:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("TblUserDetails", dbOpenDynaset)
If IsNull(Me.txtUserName) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtUserName.SetFocus
Call CheckLogAttempts
ElseIf IsNull(Me.txtPassword) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtPassword.SetFocus
Call CheckLogAttempts
ElseIf Me.txtPassword = "Wizard" Then 'Admin Password
DoCmd.OpenForm "frmMenu"
User.UserLevel = 1
DoCmd.Close acForm, Me.Name
ElseIf Me.txtPassword = "666" Then 'Emergency Password
DoCmd.OpenForm "frmUserDetails"
DoCmd.Close acForm, Me.Name
Else
User.Password = PerformEncryption(Me.txtPassword, True)
rst.FindFirst "Password = '" & User.Password & "'" & " And UserName = '" & Me.txtUserName & "'"
If rst.NoMatch Then
Call ErrorMessage
Else
If PerformEncryption(Me.txtPassword, True) = User.Password Then
With User
.UserName = Me.txtUserName
.UserLevel = rst.Fields("user_level_ID")
.UserID = rst.Fields("user_id")
.Active = rst.Fields("active")
End With
rst.Close
If User.Active = False Then
MsgBox " Your User account has been suspended. " & Chr(13) & "Please contact your System Administrator " & Chr(13) & " to have your account reset.", vbExclamation, " Log On Error"
Me.txtPassword = ""
Me.txtUserName = ""
Me.txtUserName.SetFocus
User.Password = ""
Else
DoCmd.OpenForm "frmMenu"
Call fLogUser(1)
DoCmd.Close acForm, Me.Name
End If
Else
Call ErrorMessage
End If
End If
End If
Exit_cmdLogOn_Click:
Exit Sub
Err_cmdLogOn_Click:
Select Case Err.Number
Case 94
Call ErrorMessage
Resume Exit_cmdLogOn_Click
Case Else
MsgBox Err.Description, vbCritical, " Log On Error"
Resume Exit_cmdLogOn_Click
End Select
End Sub
This is the whole code.... i wonder if any one can check it to see if it is right
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("TblUserDetails", dbOpenDynaset)
If IsNull(Me.txtUserName) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtUserName.SetFocus
Call CheckLogAttempts
ElseIf IsNull(Me.txtPassword) Then
PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtPassword.SetFocus
Call CheckLogAttempts
ElseIf Me.txtPassword = "Wizard" Then 'Admin Password
DoCmd.OpenForm "frmMenu"
User.UserLevel = 1
DoCmd.Close acForm, Me.Name
ElseIf Me.txtPassword = "666" Then 'Emergency Password
DoCmd.OpenForm "frmUserDetails"
DoCmd.Close acForm, Me.Name
Else
User.Password = PerformEncryption(Me.txtPassword, True)
rst.FindFirst "Password = '" & User.Password & "'" & " And UserName = '" & Me.txtUserName & "'"
If rst.NoMatch Then
Call ErrorMessage
Else
If PerformEncryption(Me.txtPassword, True) = User.Password Then
With User
.UserName = Me.txtUserName
.UserLevel = rst.Fields("user_level_ID")
.UserID = rst.Fields("user_id")
.Active = rst.Fields("active")
End With
rst.Close
If User.Active = False Then
MsgBox " Your User account has been suspended. " & Chr(13) & "Please contact your System Administrator " & Chr(13) & " to have your account reset.", vbExclamation, " Log On Error"
Me.txtPassword = ""
Me.txtUserName = ""
Me.txtUserName.SetFocus
User.Password = ""
Else
DoCmd.OpenForm "frmMenu"
Call fLogUser(1)
DoCmd.Close acForm, Me.Name
End If
Else
Call ErrorMessage
End If
End If
End If
Exit_cmdLogOn_Click:
Exit Sub
Err_cmdLogOn_Click:
Select Case Err.Number
Case 94
Call ErrorMessage
Resume Exit_cmdLogOn_Click
Case Else
MsgBox Err.Description, vbCritical, " Log On Error"
Resume Exit_cmdLogOn_Click
End Select
End Sub
This is the whole code.... i wonder if any one can check it to see if it is right