I have created a form for the user to enter password before accessing the system
The table password has been created with the field uname of type Text and pword of type Text. The uname is displayed as a combo box on the form. When I enter the password and click ok it says Type Mismatch (Error 13)
Here is the code:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
uname.SetFocus
End Sub
Private Sub cmd_close_Click()
DoCmd.close
End Sub
Private Sub ok_Click()
Dim rcd As Recordset
Set dbs = CurrentDb
If (IsNull(uname) Or Len(Trim(uname)) = 0) Then
s = MsgBox("Please check that you have entered your username!")
Else
If (IsNull(pword) Or Len(Trim(pword)) = 0) Then
s = MsgBox("Please check that you have entered your password!")
Else
Set rcd = dbs.OpenRecordset("select pword from password where uname='" + Me.uname + "'")
If rcd!pword = Me.pword Then
DoCmd.close
DoCmd.OpenForm "mainmenu"
Else
DoCmd.Beep
bool = MsgBox("Invalid password! Try again please")
pword = " "
pword.SetFocus
End If
End If
End If
End Sub
Thnks for your help :)