Hello. I've got VBA code (Access 2k) in a form that moves field data to 4 strings which, after some character replacement, I try to post back with a DoCmd RunSQL UPDATE:
DoCmd.RunSQL "UPDATE QARDOC_FIT_SCENARIO_TBL " & _
"SET QARDOC_FIT_SCENARIO_TBL.TCT_SCENARIO_STATUS = '" & oStatus & "', QARDOC_FIT_SCENARIO_TBL.TCT_COMPLETION_DATE = '" & oCompletionDate & "', QARDOC_FIT_SCENARIO_TBL.TCT_COMMENT = '" & oTCTComment & "' " & _
"WHERE QARDOC_FIT_SCENARIO_TBL.SCENARIO_ID = '" & oScenarioID & "';"
It compiles and saves fine, but when the update Sub runs, I get
"Run-time error '2486': You can't carry out this action at the present time"
I've seen several folks on the forums with this error who think it's a MS bug, but I've also seen several who've had it go away after being instructed to clean up the code. Can you tell me who the culprit is? Thanks.
The code itself looks ok, maybe you could insert spaces after the paramter values (don't think that matters though).
One thing to try is to use the Execute method of the database object instead (with the currentdb object it would look like
CurrentDb.Execute "UPDATE ...."). It is more flexible and likely to retrieve more accurate error information. Maybe it's just a locking issue.
I personally try to avoid to use the methods of the DoCmd object whenever possible as they mostly seem to be just there for easy macro conversion.