robertd Level: Guest

|
ADOX and Access problem! Archived to Disk
This code is cut from the MSDN Library. Why doesn't the codeline marked as [1] work against Access table? I try to make a "Autonumber" type instead of an adInteger. I also cannot find any Long type.
Sub CreateAutoIncrColumn()
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim col As New ADOX.Column
' Open the catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:Program FilesMicrosoft Office" & _
"OfficeSamplesNorthwind.mdb;"
With tbl
.Name = "MyContacts"
Set .ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId", adInteger
' Make the ContactId column and auto incrementing column
[1] .Columns("ContactId").Properties("AutoIncrement") = True
.Columns.Append "CustomerID", adVarWChar
.Columns.Append "FirstName", adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Append tbl
Set cat = Nothing
End Sub
Regards
Robert Dalan
|