About Unique Values

C

Cosmin

Anybody know how can i see if a column has the property unique set from vba (ADODB, DAO, ADO, ADOX etc.)
Thank you
 
G

Gerald Stanley

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.)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top