|
-
March 13th, 2001, 10:34 AM
#1
Creating a Table in Access with AutoNumber Field
I want to create a table with an AutoNumber Field, but I can not find information on the syntax. Is it possible?
Thanks in advance for any help.
Catrina
Here is my statement as is:
db.Execute "CREATE TABLE RateRec ([RREmp] TEXT(6), " _
& "[RRSeq] TEXT (1), " _
& "[RateDate] TEXT (8), RateRate LONG, " _
& "RecordID )"
''RecordID is the field I need set as AutoNumber
-
March 13th, 2001, 11:14 AM
#2
Re: Creating a Table in Access with AutoNumber Field
'create table
Dim tbl As ADOX.Table
Set tbl = New ADOX.Table
tbl.Name = "tblCustomer"
cat.Tables.Append tbl
'=========
Dim col As ADOX.Column
Set col = New ADOX.Column' Create first name field
With col
.Name = "FirstName"
.DefinedSize = 50
End With
' Add the new column to the table.tbl.Columns.Append colSet col = New ADOX.Column
' Create last name field.
With col
.Name = "LastName"
.DefinedSize = 50
End With
' Add the new column to the table.
tbl.Columns.Append col
'or--------shortcut to add column------
tbl.Columns.Append "FirstName", _
adVarWChar, 50
tbl.Columns.Append "LastName", _
adVarWChar, 50
'------------
'create autoincrement field
Set col = New ADOX.Column
Set col.ParentCatalog = cat
With col
.Type = adInteger
.Name = "ID"
.Properties("Autoincrement") = True
End With
tbl.Columns.Append col
Iouri Boutchkine
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|