You are on page 1of 1

Private Sub txtpwd_KeyPress(KeyAscii As Integer)

If KeyAscii = vbEnter Then


If Len(Trim(txtlogin)) > 0 And Len(Trim(txtpwd)) > 0 Then
If CheckPwd(txtlogin, txtpwd) = "ok" Then
MsgBox "Password ok"
Else
MsgBox "Wrong password or Login not found."
End If
Else
MsgBox "Login and password should not be blank"
End If
End If
End Sub
Private Function CheckPwd(cLogin As String, cPwd As String)
'in my case i will use dao. you probably using ado just convert it
Dim rs As Recordset, ret As String
Set rs = opendatabase("c:\temp\login.mdb").openrecordset("select * from
tbllogin where ucase(trim(logname)) = '" & UCase(Trim(cLogin)) & "'")
If rs.RecordCount <> 0 Then
If UCase(Trim(rs("pword"))) = UCase(Trim(cPwd)) Then
ret = "ok"
Else
ret = "wrong"
End If
Else
ret = "wrong"
End If
rs.Close: CheckPwd = ret
End Function

'This is just to give you an idea. For sure there are lot of w

You might also like