Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning a query into a table

Status
Not open for further replies.

laina222

Technical User
Sep 7, 2001
172
US
How would I turn the information I obtained from a query into a new table? My query basically selects the records that have already been reported on. I want to then take all of the records in the query and put them into a new table, and I want to be able to do this every week, so it has to be able to be done over and over again.
 
Make the query a 'Make Table' query by selecting query|Make table from the menu in the query design view. It will ask you for some information.

Hope this will help.
 
I see what you're talking about but after the query runs there's no table that's been created.
What am I doing wrong?
 
I'm sorry. Update, append, and Make table queries work sort of differently. You see the 'Red Exclamation point' in the tool bar. This will actually execute the query and create the table with the results from the query. When you run the query using the view button it only shows you the results of the query. This is actually nice because you can view the query first and make sure everything looks correct before you actually execute the query and create the table. When you click the button to Run the query or select 'Query|Run' from the menu bar it will pop up a message box telling you how many rows it is going to append in the new table. This is a last chance to cancel the operation.

Let me know if this makes sense or not. Hope this helps....
 
Even when I click on the exclamation point the table isn't created. It doesn't tell me how many rows will be appended or anything.
Before I even type in the SQL, should I select an existing table or should I name a new table to put the data into?
 
Never mind! I got it to work.
Thanks!
I have another question. Lets say I wanted to update the table I just created everyweek with additional info w/out deleting the old info. Can I do that with the same query?
 
It is up to you whether you want to add the query to a new table or an existing table. If you are adding the information to an existing table you are basically performing an append query. Maybe this will help. The following is the Access syntax for making a table. You will notice that everything is the same except that it uses the INTO keyword followed by the name of the table you want to put it in.


SELECT MyTable.Field1, MyTable.Field2, MyTable.Field3 INTO MyTable_Archive
FROM MyTable;


I would try playing with this in your sql statement. I would definately use some test table name or something to make sure you are not affecting any current tables. Doing it this way directly in your sql syntax you do not have to mess with the making the query a make table query. This will do it for you. Play with this and run the query using the exclamation point and see what happens.
 
Nope you would want to use an append query and point it to the table you want to append to. Then just load which fields you want to append and you are all set. The make table query will delete the table if it already exists and then add the new data. You can find the append query under the query menu also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top