Set key field in Make Table query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way you can set a key field for a table that is created with a
Make Table Query?
This query is run daily to update informaiton and I need a key field set to
tie other tables to it.
Thanks
 
Another approach is to use the Make Table query once to get the "bones" of
your table, modify it to include your Key field and other changes, then only
append to it after that.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
A better solution would be to change from a Make Table to an Append Query.
Make table queries are really ugly beasts. They use default field sizes,
guess at data types, and there is not (to my knowledge) any way to specifiy a
primary key until after the table is created.

If you first create your table with the correct field sizes and data types.
It is not hard to change to an append query. The only trick is, you need to
delete the data in the table before you append the new data if you want the
table to contain only the new data. Easy Enough:

CurrentDb.Execute("DELETE * FROM SomeTable;"), dbFailOnError
 
Great - thank you for the suggestion of going to an append. I actually
started with and append, but wanted only the new data in the table. Thanks
for the line of code, where should this be implimented? Is this used in the
query SQL or somewhere else?
Apprecaite your help!
 
I have the append query run from a Macro along with several operations. I
added a runSQL command just before and used "[DELETE] * FROM [myTable]" and
it worked great!!
Thank you very much!
 
Back
Top