Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/106185

From BetaArchive Wiki

ACC1x: Cannot DDE Execute RunSQL Command with Brackets


The information in this article applies to:

  • Microsoft Access 1.1


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] =

would be interpreted by Microsoft Access to be

   UPDATE Employees SET [First Name 

which is not a complete command and cannot be run successfully.


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.


Steps to Reproduce Problem

  1. Open the sample database NWIND.MDB.
  2. With Microsoft Access still running, start Word for Windows.
  3. Create and then run the following Word for Windows macro, which will use DDE to instruct Microsoft Access to change all first names in the Employees table that are Andrew to Jim:

          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 

The error message "WordBASIC Err=503 Process failed in other application" will result.

To correct the problem, enclose the SQL statement in double quotation marks, as follows:

    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
Issue type : kbbug
Technology :

Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.