I have written a window in Access that links through ODBC to a SQL database that needs to have the ability to either save or cancel. The form has been designed with this in mind and all the controls do not have a source so that when you hit save there is a docmd.runsql that inserts or edits the entries into the appropriate table. If you click on Close without Save obviously it just closes the window and ignores the changes.
The script works when the output script is run in Query Analyser but when run in Access VB it comes up with the following message.
“Syntax error (missing operator) in query expression “Description of Stuff” from updates’.
The VB Script is:
strSQL = “update updates ” & _
” set updatedate = ” & txtUpdateDate & _
“, trfrom = ‘” & TRFrom & _
“‘, trto = ‘” & TRTo & _
“‘, trreason = ‘” & TRReason & _
“‘, bmapproval = ” & chkBMApproval & _
“, bmapprovaldate = ‘” & BMApprovalDate & _
“‘, acapproval = ” & chkAccountsApproval & _
“, acapprovaldate = ‘” & ACApprovalDate & _
“‘, updatedescription = ‘” & txtDescription & _
“‘ from updates where updateid = ” & txtUpdatesID
End If
DoCmd.RunSQL strSQL
The debug.print sql is
update updates set updatedate = 16/09/2003,
trfrom = ‘Someone’,
trto = ‘Somewhere’,
trreason = ‘Because’,
bmapproval = -1, bmapprovaldate = ’01/09/2003′,
acapproval = -1, acapprovaldate = ’01/09/2003′,
updatedescription = ‘Description of stuff’
from updates where updateid = 10046
which works fine in query analyser.
Can anyone tell me what I’m doing wrong because it’s now beginning to really annoy me!!!
Many thanks.