About Unique Values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anybody know how can i see if a column has the property unique set from vba (ADODB, DAO, ADO, ADOX etc.)
Thank you
 
Uniqueness is not a property of a column but is achieved by
setting up a unique index for the column. Therefore, you
would be able to determine the information that you are
seeking by trawling through the indexes for your table,
checking whether it is unique and that it has only one
column and that column is the one that you are interested
in. It should be something like

Dim ndx As Index
For Each ndx In CurrentDb.TableDefs("{yourTableName}").Indexes
If ndx.Unique And ndx.Fields.Count = 1 And
ndx.Fields(0) = "{yourField}" Then
<do what you want to do>
End If
Next

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
Anybody know how can i see if a column has the property
unique set from vba (ADODB, DAO, ADO, ADOX etc.)?
 
Back
Top