Indexes

J

JonWayn

Since indexes dont have to be named after the field they contain, how do I
programatically determine if a field in the fields collection of a table's
index is based on a field in the fields collection of that table? IOW, if I
loop thru the fields of an index, what properties of each index.field do I
compare to properties of individual table.field objects to determine that
those fields correspond?
 
D

Douglas J. Steele

I'm not sure I understand your question. A field cannot be in an index for a
table unless it's a field in that table.

The name of the field should be all you need.
 
S

Stefan Hoffmann

howdy,
IOW, if I
loop thru the fields of an index, what properties of each index.field do I
compare to properties of individual table.field objects to determine that
those fields correspond?

TableDefs().Indexes().Fields().Name

gives you the name of the field as seen in the layout/design view of a
table. So you don't need to compare anything.


mfG
--> stefan <--
 
J

JonWayn

When an index is programatically created, it can be given a name that is not
the same as the field it is based on. In that case, comparing the
index.field's Name property to the table.Field's Name property will not be
positive. Is there some other way to tell? I tried using the is operator on
the 2 field objects but that didnt do it. The SourceField property of the
Index.Field object is documented to return a string value, however, in
usage, all I get returned is an error. Any other suggestions?
 
J

JonWayn

I know that. Both field and index belong to the same table in my question.
The question is how do you determine what field in that table an index
correspond to, bearing in mind that an index's field and its corresponding
table field do not have to bear the same name?
 
S

Stefan Hoffmann

howdy,
When an index is programatically created, it can be given a name that is not
the same as the field it is based on. In that case, comparing the
index.field's Name property to the table.Field's Name property will not be
positive.
Sorry, this is nonsense. Indexes().Fields().Name is the name of the
indexed field. E.g.

CREATE INDEX indexname ON tablename (<fieldlist>).

The names returned by Indexes().Fields().Name are equal to <fieldlist>.


mfG
--> stefan <--
 
J

JonWayn

Actually I think I have been confusing the index's name with the name of the
field it contains. So, am I to understand that if a table has an index on
the field, "First_Name", then
TableDefs("ThatTable").Indexes("Whatever").Fields("First_Name") naturally
corresponds to the field TableDefs("ThatTable").Fields("First_Name")?
 

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