g.mcavoy123
Registered User.
- Local time
- Today, 07:28
- Joined
- Dec 8, 2015
- Messages
- 32
I have been trying to create a login screen that allows the user 3 password attempts, then it will close the database. However my loop does not work correctly and the value for the users attempts does not seem to change. Please Could someone help.
Code:
Option Compare Database
Public intLogonAttempts As Long
Private Sub Command1_Click()
intLogonAttempts = 0
Do While intLogonAttemptDone <= 3
Loop
If IsNull(Me.txtLoginID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter password", vbInformation, "Password required"
Me.txtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("Surname", "tblUsers", "Surname ='" & Me.txtLoginID.Value & "'"))) Or _
(IsNull(DLookup("Password", "tblUsers", "Password ='" & Me.txtPassword.Value & "'"))) Then
Me.txtPassword = ""
intLogonAttemptDone = intLogonAttempts + 1
MsgBox "Incorrect LoginID or Password" & intLogonAttempts
Else
MsgBox "LoginID and password correct"
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMenu"
End If
Code:
Option Compare Database
Public intLogonAttempts As Long
Private Sub Command1_Click()
intLogonAttempts = 0
Do While intLogonAttemptDone <= 3
Loop
If IsNull(Me.txtLoginID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter password", vbInformation, "Password required"
Me.txtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("Surname", "tblUsers", "Surname ='" & Me.txtLoginID.Value & "'"))) Or _
(IsNull(DLookup("Password", "tblUsers", "Password ='" & Me.txtPassword.Value & "'"))) Then
Me.txtPassword = ""
intLogonAttemptDone = intLogonAttempts + 1
MsgBox "Incorrect LoginID or Password" & intLogonAttempts
Else
MsgBox "LoginID and password correct"
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMenu"
End If