Link to home
Start Free TrialLog in
Avatar of Gordon_Atherley
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").Properties("Autoincrement") = 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
ASKER CERTIFIED SOLUTION
Avatar of leonstryker
leonstryker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gordon_Atherley
Gordon_Atherley

ASKER

Aha!

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

No problem.  Thanks for the grade,

Leon