Copying and Pasting Access 2000 Queries

Paperclipper

Board Regular
Joined
Mar 11, 2004
Messages
110
Is there a faster way to copy and paste queries from db to db? i should have made a template of all the queries and then put the tables on them, but now it's too late and it would take longer...

anyone know how to do the same as selecting 10 queries and duping them on another db?

thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Maybe it would be easier to, from the Destination db, use a File->Get External Data->Import, and then Select the 10 queries that you want imported?
 
Upvote 0
If you just want to get the raw SQL, try something like this:
This iterates through the full list of queries and throws them into a msgbox just to display. You could automate an export routine sending it to another mdb or just dump the contents into a text file and work with it there.

Code:
Sub GrabSQL()
Dim db As DAO.Database
Dim qry As QueryDef
Dim strVal, strDest As String
Set db = CurrentDb()
strDest = "full_path_to_file"
 ' "C:\folder\folder1\database.mdb"
For Each qry In db.QueryDefs
  strVal = qry.Name
  DoCmd.TransferDatabase acExport, "Microsoft Access", strDest, acQuery, strVal, strVal, False
Next qry
          
End Sub

qry.SQL would give you the actual SQL in the queries. You could export that to a text file.


Mike
 
Upvote 0
thanks guys!

Dugantrain actually gave me the novice something i can use right away and did the trick!

Mike, yours was good to know ...and i'll definitely give a try if/when i get up to that level! :biggrin:

good teamwork! thanks! (y)
 
Upvote 0

Forum statistics

Threads
1,221,675
Messages
6,161,216
Members
451,691
Latest member
fjaimes042510

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top