Solved

How To Automate an Export to CSV from an Access Query

Posted on 2011-02-24
5
564 Views
Last Modified: 2012-05-11
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  
0
Comment
Question by:dawber39
  • 3
  • 2
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34976353
remove the square brackets and specify the full path to the csv file


DoCmd.TransferText acExportDelim, , "qryPriceList", "C:\YourFolderName\NewPrices.csv"
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34976358
you may also need an export specification to create a good csv file..

what version of Access are  you using?
0
 

Author Comment

by:dawber39
ID: 34976404
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
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34976418


add the option to add the field names

DoCmd.TransferText acExportDelim, , "qryPriceList", "C:\YourFolderName\NewPrices.csv",true
0
 

Author Closing Comment

by:dawber39
ID: 34976441
You people ROCK!!!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now