Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Primary Key in table

Status
Not open for further replies.

EddStewart

Programmer
Joined
Nov 9, 2000
Messages
3
Location
GB
Hi,

I'm importing a number of tables from an outside .mdb into my DB and need to automatically determine which field in the imported tables is the primary key. Can anyone help with some VBA code that can do this?

Kind Regards,

Edd Stewart
 
This page shows how to retrieve database schema using either ADOX or DAO:


I've never used DAO to do jobs like that, but using ADOX, the value you are testing for is adKeyPrimary = true.

Although this page shows how to create a primary using ADOX, it also illustrates the properties that you would interrogate (pay close attention to adKeyPrimary) if you looped through an mdb and tested each table:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top