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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Automation

Status
Not open for further replies.

GoingCrazy

Technical User
May 7, 2001
30
US
I am interested in automating my Make Table and Update queries since I have to update a number of tables on a daily basis. I have two tables I am working with...Table1 and Table2. I need to copy the information from Table1 to Table2 and then delete Table1 so I can "Make" Table1 with the new information. There is information in Table2 that then needs to be updated in Table1. I've tried the following Macro:
CopyObject 'Table1 to Table2
DeleteObject 'Table1
OpenQuery 'Make Table query
OpenQuery 'Update Table query

I've tried to keep it simple, but the only part that seems to work is the Update portion of the query. The Table1 info is not updated with the new information. I've tried using a DeleteObject for Table2 and then renaming Table1 to Table2, but that ends up deleting Table2 after it updates Table1. Because of this the macro works only once because it can't find Table2 the next time it's run. By the way, I can run each query separately and they all work great. I was just hoping to combine them into a macro to automate the process.

If anybody can help, I would greatly appreciate it. I am not proficient in VB so I don't know how to do this in a module. I am open to anything that may resolve this problem, but please provide whatever steps you can and the location for the code.

Thanks for your assistance.
 
Why are you going around in circles? If I'm reading the post correctly Table1 is copied to Table2 then it's deleted and a new empty Table1 is made which is then updated from Table2 which was Table1 to begin with.
 
Delete table2, rename table1 to table2, make table1. Joe Miller
joe.miller@flotech.net
 
I guess I should have added: Table1 begins with generic info and is fed additional information from a form after it is in place. To maintain the complete database, these fields need to be re-instated in Table1. I know there are other ways to do this, but because of the type of data maintained, this seems to be the easiest. I will try Joe's suggestion and see if that works for my needs.

Thanks
 
I just tried Joe's suggestion and I had the same results as mentioned above. The tables are updated fine, but when I put the DeleteObject in the macro, it deletes both the original Table2 and the renamed Table2. So when the macro is run again, there is no Table2 to start with. Am I missing something?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top