juniepiper27
Registered User.
- Local time
- Today, 13:32
- Joined
- Sep 24, 2014
- Messages
- 49
Dear Sir,
I have an error message or debug message in my code in username & password log in.. it has an error in if else statement
empname is a cobobox
empass is a txtbox
logempID is a autonum I.D
usrnmpass is a table name
there's an specific record in a table of usrnmpass showing in the attachment
this is my code....
Private Sub Command1_Click()
If IsNull(empname) Or empname = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
empname.SetFocus
Exit Sub
End If
If IsNull(empass) Or empass = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
empass.SetFocus
Exit Sub
End If
If empass.Value = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname.Value) Then
logempID = empname.Value
DoCmd.Close acForm, "DATABASE LOG-IN", acSaveNo
DoCmd.OpenForm "EQUIPMENT DEPARTMENT MONITORING DATABASE"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
empass.SetFocus
End If
End Sub
the error was in the if else statement above of DLookup function.. please give me the correct statement for Dlookup function..
Thanks & best regards,
I have an error message or debug message in my code in username & password log in.. it has an error in if else statement
empname is a cobobox
empass is a txtbox
logempID is a autonum I.D
usrnmpass is a table name
there's an specific record in a table of usrnmpass showing in the attachment
this is my code....
Private Sub Command1_Click()
If IsNull(empname) Or empname = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
empname.SetFocus
Exit Sub
End If
If IsNull(empass) Or empass = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
empass.SetFocus
Exit Sub
End If
If empass.Value = DLookup("[empass]", "usrnmpass", "[logempID] = " & empname.Value) Then
logempID = empname.Value
DoCmd.Close acForm, "DATABASE LOG-IN", acSaveNo
DoCmd.OpenForm "EQUIPMENT DEPARTMENT MONITORING DATABASE"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
empass.SetFocus
End If
End Sub
the error was in the if else statement above of DLookup function.. please give me the correct statement for Dlookup function..
Thanks & best regards,