[RESOLVED] password problem
I have problem here, If I enter a wrong password in the textbox I got the message MsgBox "Please put correct password.", vbCritical, "WARNING", untill three times attempts, after three time unsuccessful attempt, this form unload and frmMenu.Show appear. This Ok to me
If I enter the correct password, I got that message MsgBox "You successful enter the password" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang". This also Ok.
But after enter a wrong password, this password form unload,Then I call the form again.. and this times, I try to enter the wrong password..I got the message
MsgBox "Please put correct password.", vbCritical, "WARNING", althought I have put the wrong password more than 3 unsuccessful attempts.Why I still still got this error mesage despite I have done more than 3 unsuccessful attempts to enter the new form frmMenu.Show.:confused:
Code:
Private Sub cmdOK_Click()
Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Recordset
Dim cs As String
'cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\DBMS.mdb" & ";Persist Security Info=False;"
cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\DBMS.mdb" & ";Jet OLEDB:Database Password=macres;"
adoConn.ConnectionString = cs
adoConn.Open
If Text2.Text = "" Then
MsgBox "Please put your password", vbCritical, "Kata laluan"
Text2.Text = ""
Text2.SetFocus
Else
usrnm = Text2.Text
adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';",
adoConn, adOpenStatic, adLockOptimistic
If adoRS.Fields("Password").Value = Text2.Text Then
pass = True
'if password valid, success
MsgBox "You successful enter the password" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
Unload Me
Form1.Show
Unload frmMenu
Else
'if password invalid,message box ask to insert invalid password
intCounter = intCounter + 1
If intCounter = 3 Then
Unload Me
frmMenu.Show
Else
MsgBox "Please put correct password.", vbCritical, "WARNING"
Text2.Text = ""
Text2.SetFocus
End If
End If
End If
End Sub