Microsoft KB Archive/106244

From BetaArchive Wiki
Knowledge Base

ACC: "Incorrect Syntax Near '-'" Using TransferDatabase Action

Article ID: 106244

Article Last Modified on 5/6/2003


  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition

This article was previously published under Q106244


Advanced: Requires expert coding, interoperability, and multiuser skills.

When you are running a TransferDatabase macro action to attach a SQL Server table, the following error message may be generated:

Connection Failed. SQL State 37000. SQL Server Error 102. Incorrect Syntax Near '-'.

NOTE: This behavior no longer occurs in Microsoft Access for Windows 95, version 7.0.


This error is generated because there is an error in the database name argument, or connect string, of the TransferDatabase macro action.

The Microsoft Access Help system suggests that the connect string can be copied from the table properties of the attached table. When you copy the connect string into the database name argument, a string similar to the following example is produced:

NOTE: In the following example, an underscore (_) is used as a line- continuation character. Remove the underscore when re-creating this example.

   ODBC;DSN=MyServer;UID=User2;APP=Microsoft Access;WSID=User2; _

The syntax error is caused by the text after the "pubs" database name. All text after the database name should be removed from the string, and the table name should be moved to the source argument.

The following example demonstrates correct arguments for the TransferDatabase action:

   Transfer Type:  ATTACH.
   Database Type:  <SQL DATABASE>.
   Database Name:  ODBC;DSN=MyServer;UID=User2;APP=Microsoft Access; _

   Object Type:    TABLE
   Source:         DBO.AUTHORS
   Destination:    DBO_AUTHORS
   Structure Only: NO

Additional query words: transfer

Keywords: kberrmsg kbinfo kbusage KB106244