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

Output a query to a text file 2

Status
Not open for further replies.

WynneSMI

Programmer
Dec 16, 2002
76
0
0
US
I can't figure out how to properly output a query to a file. I need to export a query in ascii, comma delimited format. Can anyone help??? Thanks.
 
Here's the easiest way.

syntax: DoCmd.OutputTo objectType, [objectName], [Format], [newFile], [autoStart]

example: DoCmd.OutputTo acQuery, "q_ClientName", "MS-DOSText(*.txt)", "c:\query.txt", True, ""

Dan
 
1. Run the query
2. File > Export
3. Navigate to the folder to save in
4. Choose "text files" from the file type box
5. Give the output file name a ".csv" extension
6. Click Save
7. Let the Wizard walk you through the rest
(or just click Finish -- you've probably got all
you need at this point)
 
Thanks, RBCDS yours works but its not a comma-delimited file. mikevh yours works even better, I got the file as a comma-delimited file, but is there a way to do it by doing what you just showed me mikevh in VBA? Thanks.
 
try it:
DoCmd.OutputTo acQuery, "my query name", "MS-DOSText(*.txt)", "my text file name", False, ""
 
DoCmd.TransferText acExportDelim, , YourQueryName, YourOutPutFileName

Make sure YourOutPutFileName includes the full path
where you want the file to go and ends in ".csv".
 
Thanks mikevh!!! That's what I was looking for and it works!!! Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top