Hi Guys!
I am having trouble with the following code. Every time I click on the command button I get the error message below. I think there is something with the sql statement. Please help.:
Error Message:
Runtime error 3075
Syntax error (missing operator) in query expression 'Last Name=Manan Hotak'.
The following is the code:
Private Sub ChangePassword_Click()
Dim strsql As String
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboCurrentEmployee) Or Me.cboCurrentEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Program"
Me.cboCurrentEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the old password box
If IsNull(Me.oldpassword) Or Me.oldpassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Program"
Me.oldpassword.SetFocus
Exit Sub
End If
'Check value of password in Users to see if this
'matches value chosen in combo box
If Me.oldpassword.Value = DLookup("Password", "Users", "[Last Name]=""" & Me.cboCurrentEmployee.Value & """") Then
strsql = "UPDATE Users SET password=" & "'" & Me.NewPassword.Value & "' WHERE Last Name=" & Me.cboCurrentEmployee.Value
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
MsgBox "Password has been changed", vbInformation, "Password Changed"
Else
MsgBox "The Old Password does not match", vbInformation, "Type Correct Old Password"
Exit_Command6_Click:
Exit Sub
Err_ChangePassword_Click:
MsgBox Err.Description
Resume Exit_ChangePassword_Click
End If
End Sub