Hi, I have this set of coding when i use it when i am in ms access 97 but not ms access 2007. this is a set of coding for login form of ms access. Whenever i log in with the correct userid and password, it always promt me "wrong password!! enter again"
i think that this is the part "mark in red" where the error came in.


rst.Index = "prima"
.Seek "=", luserid, lpwd

If .NoMatch Then


If b < 10 Then
b = b + 1
Msg = "Wrong password!! Enter again"
Style = vbOKOnly + vbCritical
Title = "Login"
Response = MsgBox(Msg, Style, Title)
tpwd.SetFocus
tpwd.Text = String(20, " ")
.Bookmark = varbook
.Edit
!num = b + !num
.Update

For your info, prima is the index for userid only.

If it is just for login form then why you are using .update and .edit your code is confusing but you can use simply this code for login

On Error GoTo errHandler
Set rs = db.OpenRecordset("SELECT COUNT(*) As Numrows FROM users WHERE LCASE(username) = '" & LCase(txtusername.Text) & "' AND LCASE(pw) = '" & LCase(txtpassword.Text) & "'")
If CInt(rs.Fields!Numrows) > 0 Then
   MsgBox "YOU HAVE SUCCESSFULLY SIGNED IN", vbOKOnly, "EXCELLENT ACADEMY"
   frmMenu.Show
   Unload Me
Else
   MsgBox "LOGIN DENIED PLEASE TRY AGAIN!!"
   txtusername.Text = ""
   txtpassword.Text = ""
   txtusername.SetFocus
End If
Exit Sub
errHandler:
   MsgBox (Err.Description)
commented: Nicely done. +4

Nice solution Naveed.:) More kudos your way...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.