Programmatically set table field order

H

hollyylloh

I need to programatically set the order of fields in a table that will later
be exported. I do not know where to start.

Hope you can help.
 
D

Dirk Goldgar

hollyylloh said:
I need to programatically set the order of fields in a table that will
later
be exported. I do not know where to start.


The easiest thing to do is just to create a query that orders the fields the
way you want, and then export that query.

If you really have to, it is possible to use DAO to manipulate the order of
fields in the TableDef (table definition). But I really don't recommend it.
 
M

Michael J. Strickland

hollyylloh said:
I need to programatically set the order of fields in a table that will
later
be exported. I do not know where to start.

Hope you can help.


Try checking out the "OrdinalPosition" property of the field object.
This is a number which sets the field position. Multiple fields can have
the same "OrdinalPosition" value in which case they will appear in
alphabetical order by field name.

Be warned though, I have had problems using ordinal position in Access
2007.

For example, in a table with 5 fields, the following procedure will
incorrectly display a new field in the last position in Table View even
though it appears in the correct position in Design View:

1. Add a field, setting its ordinal position to make it the 2nd field.
2. Delete this field in Table View.
3. Add the field again.

If you delete the field in Design View instead of Table View (in step
2), then
all is well and the re-added field shows up in the correct position in
Table View also.

In the case where the field shows up incorrectly in the last position in
Table View, you can correct this by going into design view, moving the
field to a new location and then moving it back.

For some reason the field positions are not refreshed correctly when a
field is deleted in Table View.
 

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