How To Automate an Export to CSV from an Access Query

I created a query that will produce a list of only the products that have price changes in effect. The query needs to be exported to a csv file and be uploaded to an FTP site. I would like to automate the exporting of the query - so that it will be less complicated for certain individuals.

I have tried creating a module "ExportQuery with the following code:

Function ExportQuery()
DoCmd.TransferText acExportDelim, , "[qryPriceList]", "[NewPrices].csv"

End Function

I get an error stating it cannot find qryPriceList - and to make sure it is spelled correctly. It is spelled correctly - so I am a little lost here - any help would be greatly appreciated  
Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:

add the option to add the field names

DoCmd.TransferText acExportDelim, , "qryPriceList", "C:\YourFolderName\NewPrices.csv",true
Rey Obrero (Capricorn1)Commented:
remove the square brackets and specify the full path to the csv file

DoCmd.TransferText acExportDelim, , "qryPriceList", "C:\YourFolderName\NewPrices.csv"
Rey Obrero (Capricorn1)Commented:
you may also need an export specification to create a good csv file..

what version of Access are  you using?
dawber39Author Commented:
I am using 2007 but I will be implementing its use in 2003 - that does seem to work - is there a way I can get it to retain the column headers - because the program that is reading it - starts at the second row assuming report headers
dawber39Author Commented:
You people ROCK!!!
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.