I have a make table query that does everthing i want except create a autonumber primary key. None of the tables I have in the query have primary keys, but I want the make table query to make on. Can this be done?
Thanks
Yes, this can be done but not from within the Make-Table query. You have to execute VBA code to create the additional field and the primary key. Try the following and change the names of the query, database, table, and field to your specific needs.
DoCmd.Setwarnings false
docmd.OpenQuery "qryMakeTable"
DoCmd.SetWarnings true
Dim db as DAO.Database
Set db = OpenDatabase("c:\FolderName\YourDatabase.mdb", True, False)
db.Execute "ALTER TABLE tblYourTable ADD COLUMN RecCounter AUTOINCREMENT"
db.Execute "CREATE INDEX RecCounter ON tblYourTable (RecCounter) WITH PRIMARY;"
Let me know if this works for you. I use it all of the time.
db.close Bob Scriver
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.