i am learning how to verify userid and password entered by the users. it seems to be working except the part when the wrong userid or password is entered. here is my code:
Dim db As Database
Dim rst1 As Recordset
Set db = CurrentDb
Set rst1 = db.OpenRecordset("Select * From passwordtest Where [UserId]= '" & txtuserid & "'And [password] = '" & txtpswd & "'")
If IsNull(Me![txtpswd]) Then
MsgBox "Missing Password information." & vbCrLf & "Please enter information Now or Cancel!", vbOKOnly + vbExclamation, "Password Info"
Me![txtpswd].SetFocus
Exit Sub
End If
If rst1("password") = Me![txtpswd] And rst1("userid") = Me![txtuserid] Then
MsgBox "successful!", vbExclamation
Else
MsgBox "invalid password", vbExclamation
End If
Exit Sub
End Sub
i cant make it display the message "invalid password", instead it gives me an error message "no current record", run time error! whats wrong with my code? please help!
Dim db As Database
Dim rst1 As Recordset
Set db = CurrentDb
Set rst1 = db.OpenRecordset("Select * From passwordtest Where [UserId]= '" & txtuserid & "'And [password] = '" & txtpswd & "'")
If IsNull(Me![txtpswd]) Then
MsgBox "Missing Password information." & vbCrLf & "Please enter information Now or Cancel!", vbOKOnly + vbExclamation, "Password Info"
Me![txtpswd].SetFocus
Exit Sub
End If
If rst1("password") = Me![txtpswd] And rst1("userid") = Me![txtuserid] Then
MsgBox "successful!", vbExclamation
Else
MsgBox "invalid password", vbExclamation
End If
Exit Sub
End Sub
i cant make it display the message "invalid password", instead it gives me an error message "no current record", run time error! whats wrong with my code? please help!