Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Sep 2006
    Posts
    166
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax error (Access 2000)

    I want to make a code for creating a new table but i get the error syntax error in field definition:
    Dim str As String
    str = " CREATE TABLE ThirdTable (Productid Autonumber, Items4 Single, ProductID Constraint PRIMARY KEY)"
    CurrentDb.Execute str
    Could you help me ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Syntax error (Access 2000)

    Jet SQL uses other names for some of the data types. Use COUNTER or AUTOINCREMENT instead of AutoNumber. The official term for Single is REAL, but Single is accepted too.
    For a single-field key, you *must* specify the key immediately after the field definition, not separately, and you must provide a name for the key.

    Note: although str is allowed as name for a variable, it is also the name of a built-in function, so it is better to avoid it. Use strSQL instead.

    Dim strSQL As String
    strSQL = "CREATE TABLE ThirdTable (Productid AUTOINCREMENT Constraint PrimaryKey PRIMARY KEY, Items4 Single)"
    CurrentDb.Execute strSQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •