Attribute of an Index No Duplicates field ??? 
Author Message
 Attribute of an Index No Duplicates field ???

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?



Sun, 10 Oct 2004 06:38:05 GMT  
 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?



Sun, 10 Oct 2004 07:21:15 GMT  
 Attribute of an Index No Duplicates field ???
i figured it must be there..."somewhere":o)....that's just what the doctor
ordered...thanx very much :o)


Quote:
> 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


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



Sun, 10 Oct 2004 17:21:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Access97 Field Attributes that are not in the Attributes collection of that Field

2. Recordset update fails (Duplicate Index Value on autonumber field) after AddNew

3. Setting Indexes on Memo Fields: No Duplicates: Only First 250 Bytes Considered

4. Foreign key indices being duplicated and showing up in table design index list

5. Indexed Fields to allow multiple blanks, but nothing else duplicated

6. Duplicated records in primary key index field

7. Change index from No duplicates to duplicates allowed

8. Indexing question: Separate Index on Field in Compound Primary Key

9. Primary Key index vs Field index?

10. Index Fields, Stylerefs within, working kludge indexes to document's ou


 
Powered by phpBB® Forum Software © phpBB Group