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

Output Access 2000 query results to a CSV file 1

Status
Not open for further replies.

DomFino

IS-IT--Management
Jul 9, 2003
278
US
I have four Access queries that I have to routinely open in Access then open the tools analyze with MS Excel, and then save as CSV file. Is there an easy way to go from an Access Query to creating a CSV file using VB?
 
DoCmd.TransferText acExportDelim, , "qselEmployees", "C:\Emps.csv", True

The True is to add column headings.

Duane
MS Access MVP
 
dhookom,
Thank you so much. It works great and does exactly what I needed done.
DomFio
 
Hello Duane

Melanie again.

1) Is there a way to prompt for the filename?
2) Can fields be specified or does it have to be all?

TIA,
Melanie
 
You can prompt for a file name
Dim strFileName as String
strFileName = InputBox("Enter a file name")
DoCmd.TransferText acExportDelim, , "qselEmployees", strFileName, True

All fields in your query will be exported. For a much more flexible solution check out the QBF in the Corp Tech Demos at Users can select any fields, set criteria, and output to CSV, XLS, HTML,...

Duane
MS Access MVP
 
Thanks very much. I downloaded that demo. It's fantastic.

Melanie

 
thanx, I have since updated the QBF to send to a graph as well as adding Totals/Group By functionality.

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top