Createfield - nominiating position

A

Andrew

Hi,

I'm using the folowing method to insert a column. It inserts 'Col_D' after
the very last column ('Col_F'). How do I get it to insert it after the third
existing column. The name of the column is 'Col_D' and the table goes up to
'Col_F'.

Set tdfNew = myDB.TableDefs("Test")
tdfNew.Fields.Append tdfNew.CreateField("Col_D", dbText)

Andrew
130808
 
D

Dirk Goldgar

Andrew said:
Hi,

I'm using the folowing method to insert a column. It inserts 'Col_D'
after
the very last column ('Col_F'). How do I get it to insert it after the
third
existing column. The name of the column is 'Col_D' and the table goes up
to
'Col_F'.

Set tdfNew = myDB.TableDefs("Test")
tdfNew.Fields.Append tdfNew.CreateField("Col_D", dbText)


After creating and appending the field, try:

tdfNew.Fields("Col_D").OrdinalPosition = 3
tdfNew.Fields("Col_E").OrdinalPosition = 4
tdfNew.Fields("Col_F").OrdinalPosition = 5
 
T

Tom van Stiphout

On Tue, 12 Aug 2008 20:09:01 -0700, Andrew

New fields are added at the end. You have to go out of your way to
affect the position. Fortunately there really is no reason for
worrying about position, because you would typically not use the raw
tables, but instead use queries where you can re-order the fields if
you like.

-Tom.
Microsoft Access MVP
 
A

Andrew

Thanks Tom.

I knew about the order facility in queries but this is just me being
pedantic. Dirk Goldgar was able to assist and it works a treat!

Thanks again.
 
C

Chris O''''Neill

Andrew said:
Thanks Tom.

I knew about the order facility in queries but this is just me being
pedantic. Dirk Goldgar was able to assist and it works a treat!

I thought *I* was the only pedantic person around here! :D

Regards, Chris
 

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