I have an edit button that when clicked should edit the values in my tblContacts. The code attached to the button is:
When clicked, I get an error message saying "Syntax Error in UPDATE statement"
Any help????
Matt
Code:
Private Sub cmdEdit_Click()
On Error GoTo Err_cmdEdit_Click
Dim strSQL As String
strSQL = "UPDATE tblContacts SET"
strSQL = strSQL & "chrFirstName = " & Me.txtFirstName.Value + "',"
strSQL = strSQL & "chrLastName = " & "'" & Me.txtLastName.Value + "',"
strSQL = strSQL & "chrAddress1 = " & "'" & Me.txtAddress1.Value + "',"
strSQL = strSQL & "chrAddress2 = " & "'" & Me.txtAddress2.Value + "',"
strSQL = strSQL & "chrCity = " & "'" & Me.txtCity.Value + "',"
strSQL = strSQL & "chrState = " & "'" & Me.txtState.Value + "',"
strSQL = strSQL & "chrZipCode = " & "'" & Me.txtZipCode.Value + "',"
strSQL = strSQL & "chrPhoneNumber = " & "'" & Me.txtPhoneNumber.Value + "',"
strSQL = strSQL & "WHERE lngContactID = Me.txtCID.Value"
DoCmd.RunSQL strSQL
Exit_cmdEdit_Click:
Exit Sub
Err_cmdEdit_Click:
MsgBox Err.Description
Resume Exit_cmdEdit_Click
End Sub
When clicked, I get an error message saying "Syntax Error in UPDATE statement"
Any help????
Matt
Last edited: