Createfield - nominiating position

  • Thread starter Thread starter Andrew
  • Start date Start date
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
 
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
 
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
 
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.
 
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
 
Back
Top