How to run a "one-time" DoCmd in Access ?

M

Mel

- I have a query (qryX) getting data from several tables.
- I need to export the results of this query to a comma delimited file
so I can load it into a spreadsheet (Excel)
- File > Export is grey'd out and not available.
- I mostly use the Access menu's and have not used much code.

I understand that this line of code will do the trick...

DoCmd.TransferText acExportDelim, "Standard Output", "External
Report", "C:\Txtfiles\MyText.csv"

- I think I can create a button on a form and put the DoCmd in the
Click event...
- BUT I only want to do this once... so I don't really need to create
a special menu and button.

My Question:
1 - How to modify the above DoCmd so that it get's data from my querry
qryX?
2 - How can I run the l "DoCmd" to output qryX as a csv file without
creating a button and a click event?

Thanks for any help.
 
T

Tom van Stiphout

On Sun, 9 Aug 2009 07:24:55 -0700 (PDT), Mel <[email protected]>
wrote:

Open an Access database and hit Ctrl+G. The code window opens, and
focus is on the Immediate window. Enter your line of code in that
immediate window, all on one line. Replace "Standard Output" with
"qryX". You may also want to adjust the last argument. Then hit Enter.

-Tom.
Microsoft Access MVP
 
M

Mel_3

Thanks Tom.

That is what I wanted.

Here is an alternate way... by creating a macro... presented step by
step...

http://www.databasedev.co.uk/export-macro.html

This can be useful in that you can open the macro in design view
anytime an put in the name of any query...

so you always have it available in any data base your working on.

Thanks again for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top