Determine primary key fields in VBA

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

(untested)

dim db as database, td as tabledef, inx as index, fld as field
set db = currentdb()
set td = db.tabledefs![YourTableNameHere]
for each inx in td.indexes
if inx.primary then
for each fld in inx.fields
msgbox fld.name
next
endif
next
set td = nothing
set db = nothing

HTH,
TC
 
In a VBA application I need to know which fields of an
existing Access table are the primary key fields.
How do I do this?

thanks,
Tik Sin
 
Back
Top