Gordon_Atherley
asked on
ADOX Autoincrement property gives runtime error with VB6
Experts, your help please
I'm attempting to use ADOX in VB6 to add an autoincrement field to a Table in an Access database and make it the primary key
The following snippet gvies a runtime error when it attempts to set the Autoincrement property to true
Set oTable = oTables.Item("MyTable")
With oTable
.Columns.Append "PriKey", adInteger
.Columns("PriKey").Propert ies("Autoi ncrement") = True
.Keys.Append "MyTable", adKeyPrimary, .Columns("PriKey")
End With
I've tried various alternatives for this code but always the error is always at the same point.
Solutions or workarounds, please
I'm attempting to use ADOX in VB6 to add an autoincrement field to a Table in an Access database and make it the primary key
The following snippet gvies a runtime error when it attempts to set the Autoincrement property to true
Set oTable = oTables.Item("MyTable")
With oTable
.Columns.Append "PriKey", adInteger
.Columns("PriKey").Propert
.Keys.Append "MyTable", adKeyPrimary, .Columns("PriKey")
End With
I've tried various alternatives for this code but always the error is always at the same point.
Solutions or workarounds, please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No problem. Thanks for the grade,
Leon
Leon
ASKER
Now I see the technique. Append an index which becomes the primary key.
This is the insight I needed, thank you very much Leon
Gordon