Is there a VBA code to let export a query from MS ACCESS file, export it as a TABLE to another MS ACCESS file ?

Is there a VBA code to let export a query from MS ACCESS file, export it as a TABLE to another MS ACCESS file ?
iymanbAsked:
Who is Participating?
 
John TsioumprisSoftware & Systems EngineerCommented:
Well the code should look like this
Docmd.RunSQL("SELECT * INTO [TheNameOfTheTable] FROM [TheSourceQuery]")

Open in new window

This will create a temp table in your Database
The you run this command
DoCmd.TransferDatabase acExport, "Microsoft Access", "The Full Path To The Destincation Database", acTable, "TheNameOfTheTable", "TheNameForTheDestinationTable"

Open in new window

0
 
iymanbAuthor Commented:
OK ,
This is fine, creating a TEMP table, then exporting is fine.

To create a temp table, isn't there a VBA code to replicate an existing query directy into a table, as the SQL statement is lengthy; and is difficult to put inside VBA code
0
 
iymanbAuthor Commented:
The lines of VBA code you provided were really helpful , Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.