Results 1 to 4 of 4

Thread: can you do this?

  1. #1

    Thread Starter
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545

    can you do this?

    Hi,

    Can you create an autonumber field when you are creating a table like this? If so, how????
    VB Code:
    1. mySQLstring = "CREATE TABLE " & resTableName & " (ResNumber LONG, CustomerID LONG, ReservationDate DATETIME, FreeDay LONG, Status TEXT (50) );"
    2.         mydb.Execute mySQLstring

  2. #2
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Create table Table_name (Field1_Name integer IDENTITY(1,1))

    This owrks on SQL server, and access 2000...
    Leather Face is comin...


    MCSD

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    is that via ADO??? I just tried it via DAO and got an error when trying to use the syntax

    (Field1_Name integer IDENTITY(1,1))

    in access 2000

    just asking because by his variable names it looks like he is using DAO

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    use COUNTER

    VB Code:
    1. Option Explicit
    2. Private db As Database
    3. Private Sub Command1_Click()
    4. Dim sql As String
    5.  
    6. 'create the database
    7. Set db = CreateDatabase("C:\NewDB.MDB", dbLangGeneral, dbVersion40)
    8.  
    9. 'add a table with some fields
    10. sql = "CREATE TABLE TestTable (ID COUNTER, SetName TEXT(50), SetVal TEXT(255), Description TEXT(255))"
    11. db.Execute sql
    12.  
    13. End Sub

    sql will create a field called ID which will be an autonumber field.
    -= a peet post =-

Posting Permissions

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



Click Here to Expand Forum to Full Width