Adding one table to another with INSERT INTO?

DouglasMacArthur

New member
Local time
Today, 09:45
Joined
May 19, 2016
Messages
5
I made the thread earlier where I ran into this problem, but my initial issue that the thread was about was solved so I figured I'd just start a new one to solve this issue rather than complicate things.

Anyway, I need to append a temporary table to a master table, then wipe the temporary table. The following is what I have:

CurrentDb.Execute "INSERT INTO mainTable SELECT * FROM Table1"

CurrentDb.Execute "DELETE * From Table1"

'where Table1 is the temporary table and mainTable is the master table

This is inside of a loop, as this needs to be done multiple times with different data. Each time, the temporary table is populated before this code. I have also verified that the delete query works, it's just that the INSERT INTO does not. No compile error, just mainTable remains empty (both tables do have the exact same fields).

What am I doing wrong here?

Thanks!
 
if you use queries instead of SQL, access wont let you get the syntax wrong.
then your code would be:

docmd.openquery "qaInsertRecsFromTmp"
docmd.openquery "qdDelRecsFromTmp"
 
I'm not exactly sure why, but the problem wasn't the code, it was one of the fields. It was in both tables, but for some reason when I excluded it from the query everything works perfectly. Luckily, I don't even need that field (for reference, it was an "attachments" field type).

Thanks for the help, though. I'll mark this and the other thread as solved!
 

Users who are viewing this thread

Back
Top Bottom