Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

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
0
Gordon_Atherley
Asked:
Gordon_Atherley
  • 2
1 Solution
 
Gordon_AtherleyAuthor Commented:
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

0
 
leonstrykerCommented:
No problem.  Thanks for the grade,

Leon
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now