Add AutoNumber firld to a Table using VBA

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
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:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top