
Attribute of an Index No Duplicates field ???
Hi,
You have to look at the Indexes collection
of the TableDef Object.
Here is a snippet of code that cycles through
the Indexes in a table. You would want to
check for Unique instead of Primary:
Dim db As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim idx As DAO.Index
Dim strFields As String
Dim strSql As String
Dim strPk As String
Dim i As Integer
Set db = CurrentDb()
'strTable is passed into the function
Set tbl = db.TableDefs(strTable)
'get the primary key(s)
For Each idx In tbl.Indexes
If idx.Primary = True Then
For i = 0 To idx.Fields.Count - 1
MsgBox idx.Fields(i).Name
strPk = idx.Fields(i).Name
Next i
End If
Next idx
HTH
Dan Artuso, MVP
Quote:
> i'm trying to copy some field across excluding (indexed No Duplicates)
> fields.....but...i cant find the right attributes to trap
> ....any ideas...????
> i've used....
> MsgBox .Fields(x%).Attributes
> ..but i cant understand why the attributes dont change....when i change the
> field from 'indexed no-duplicates' to normal.....and vice
> versa....???....surely i must be able to trap it?