ACC1x: Cannot DDE Execute RunSQL Command with BracketsID: Q106185
|
You receive an error message indicating that the process has failed when you use DDE from a DDE client application such as Microsoft Word for Windows or Microsoft Excel to run the RunSQL macro action in Microsoft Access version 1.1.
The SQL statement you are trying to run with the RunSQL command contains
square brackets. When Microsoft Access receives the command it assumes that
the first right square bracket marks the end of the command. For example,
the command
UPDATE Employees SET [First Name] = 'Jim' WHERE [First Name] =
'Andrew';
UPDATE Employees SET [First Name
The SQL command must be enclosed in double quotation marks in the DDE
execute string.
The SQL command in the example above could be successfully sent as:
"[RunSQL "UPDATE Employees SET [First Name] = 'Jim' WHERE
[First Name] = 'Andrew';"]"
Microsoft has confirmed this to be a problem in Microsoft Access version 1.1. This problem no longer occurs in Microsoft Access version 2.0.
Sub MAIN
SQL$ = "UPDATE Employees SET [First Name] = 'Andrew' "
SQL$ = SQL$ + "WHERE [First Name]= 'Jim';"
chan = DDEInitiate("MSACCESS", "System")
DDEExecute chan, "[RunSQL " + SQL$ + "]"
DDETerminate chan
End Sub
Sub MAIN
QT$ = Chr$(34)
SQL$ = "UPDATE Employees SET [First Name] = 'Jim' "
SQL$ = SQL$ + "WHERE [First Name]= 'Andrew';"
chan = DDEInitiate("MSACCESS", "System")
DDEExecute chan, "[RunSQL " + QT$ + SQL$ + QT$ + "]"
DDETerminate chan
End Sub
Keywords : kbinterop
Version : 1.1
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: March 26, 1999