Hello Everyone,
I have successfully created a login page for my Order Processing System. When I enter my Username and Password correctly it logs in successfully and moved onto my next form called 'frmWelcome'. However if I enter the incorrect Username and Password I get Error:
Run-time Error '13' : Type Mismatch
I have tried everything, anyone that can help me?
I have successfully created a login page for my Order Processing System. When I enter my Username and Password correctly it logs in successfully and moved onto my next form called 'frmWelcome'. However if I enter the incorrect Username and Password I get Error:
Run-time Error '13' : Type Mismatch
I have tried everything, anyone that can help me?
Code:
Option Compare Database
Option Explicit
Private Sub Form_load()
'When the form loads the enter form will open
DoCmd.OpenForm "frmLogin"
End Sub
Private Sub cmdLogin_Click()
'The dlookup funtion allows the records to be searched within the required table
If txtPassword.Value = DLookup("[Password]", "tblUsers", "[UserName]='" & txtUserName.Value & "'") Then
'This is opening the main menu and then closing the form enter
DoCmd.OpenForm "frmWelcome"
DoCmd.Close acForm, "frmLogin"
'txtusername.Value = Null
'txtpassword.Value = Null
ElseIf (txtUserName.Value) Then
MsgBox "Enter Username and Password", vbCritical, "Error"
txtPassword.Value = ""
txtUserName.SetFocus
ElseIf (txtPassword.Value) Then
MsgBox "Enter password", vbCritical, "Error"
txtPassword.SetFocus
Else
'If incorrect details are entered into any of the fields and enter is selected this would display an error message
MsgBox "Log in details are incorrect, Please try again", vbCritical, "Error"
'Both the fields would clear
txtUserName.Value = Null
txtPassword.Value = Null
txtUserName.SetFocus
End If
End Sub
Private Sub txtUserName_LostFocus()
'after the user leaves the colour text box, convert the entered
'colour to proper case, e.g. all words start with upper case letters
txtUserName.Value = StrConv(txtUserName, vbProperCase)
End Sub
Private Sub cmdExit_Click()
'This closes the forms down completely
DoCmd.Quit
End Sub
Last edited: