Add AutoNumber firld to a Table using VBA

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,690
I a MakeTable Query. I want to add an AutoNumber field to that table after the query is run. Is there a way to do that using VBA?
tbl_vluVendor_MakeTable

FOUND THE ANSWER: CurrentDb.Execute "ALTER TABLE tbl_vluVendor_MakeTable ADD COLUMN ColumnName COUNTER"


Thanks!
 
Last edited:

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,690
Re: Access: Add AutoNumber firld to a Table using VBA

FOUND THE ANSWER: CurrentDb.Execute "ALTER TABLE tbl_vluVendor_MakeTable ADD COLUMN ColumnName COUNTER"

Thanks
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,818
Office Version
365
Platform
Windows
Re: Access: Add AutoNumber firld to a Table using VBA

Just a note:

With a MAKE TABLE query, you are kind of at the mercy of Access, it sets the fields up as it thinks it should be (which may not always be what you want).
What I often do instead of a MAKE TABLE query, is I set up the shell of my table exactly as I want (with all the fields, data type, key, fields, etc I want), and then simply use an APPEND QUERY to write the records to this table.
If it is something I need to re-use, I will just including coding to delete all the current records out of the table each time.
 

Forum statistics

Threads
1,085,932
Messages
5,386,829
Members
402,020
Latest member
tsfan74

Some videos you may like

This Week's Hot Topics

Top