[AccessD] Create table with autonumber and PK

Drawbridge.Jack at ic.gc.ca Drawbridge.Jack at ic.gc.ca
Fri Jun 11 08:48:11 CDT 2004


John:

Try this syntax:

Sub jack1()
Dim dbs As Database

Set dbs = CurrentDb()

    ' Create a table with three fields and a primary
    ' key. One field with Autonumber.
 
dbs.Execute "CREATE TABLE table1 (field1 COUNTER CONSTRAINT" & _
            "MyFieldConst PRIMARY KEY, field2 TEXT(50), Field3 Date);"
dbs.Close


End Sub


Good luck.

jack
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of jwcolby
Sent: Friday, June 11, 2004 9:15 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Create table with autonumber and PK


Folks,

I have a create table query that creates a table but does not set the PK or
setup the PK as an autonumber.

CREATE TABLE MemberDetails
(
    MemberId integer,
    FirstName varchar(50),
    LastName varchar(50),
    DateOfBirth date,
    Street varchar(100),
    City varchar(75),
    State varchar(75),
    ZipCode varchar(12),
    Email varchar(200),
    DateOfJoining date

)

Is it possible to do this?

The ID should be a long, and should be set as an autonumber, and as the PK.
How do you do that in SQL?

John W. Colby 
www.ColbyConsulting.com


-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list