Hello All: I cannot figure out the syntax needed for a RunSQL command in Access. I'm getting the error related to the strSQL on a button click event that says "Run-time error 3075 Syntax error (missing operator) in query expression 'abc text abc text'. I just can't figure out what operator is missing or if I'm omitting some single quotes somewhere in the strSQL.
What I'm trying to do is enter in text for the ChangedProgramName and then click a button on the subform to update the ProgramName value in tbl_ProgramsAdult, then requery the dataset so the combo box has the refreshed information on next load. The code bombs out on the DoCmd.RunSQL strSQL line.
If anyone can assist I would be grateful. Here's my code:
Button = cmd_ProgramsAdult_UpdateProgName
Table to be Updated = tbl_ProgramsAdult
Text Box where String is Taken From = Me.ChangedProgramName
PKey in Table to be Updated = tbl_ProgramsAdult.ProgramID
Text Box where PKey is Found = Me.txtProgramID
------------
Private Sub cmd_ProgramsAdult_UpdateProgName_Click()
On Error GoTo Err_cmd_ProgramsAdult_UpdateProgName_Click
strSQL = "UPDATE tbl_ProgramsAdult" & _
" SET tbl_ProgramsAdult.ProgramName = " & Me.ChangedProgramName & _
" WHERE tbl_ProgramsAdult.ProgramID = " & Me.txtProgramID
DoCmd.RunSQL strSQL
DoCmd.Requery
DoCmd.Close
Exit_cmd_ProgramsAdult_UpdateProgName_Click:
Exit Sub
Err_cmd_ProgramsAdult_UpdateProgName_Click:
MsgBox Err.Description
Resume Exit_cmd_ProgramsAdult_UpdateProgName_Click
End Sub
---------
Thank you!