Ms Access script to export csv file

Posted on 2011-02-26
Last Modified: 2012-05-11

I have an MS Access database and would like to be able to run a script that automatically selects records from my contacts table and exports them to a csv file. is it possible to automate this? Ideally in versions 2003 & 2007

Question by:Lmillard
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 34987839
Yes this is possible, would you provide some additional details, please.

Accepted Solution

jo_m earned 500 total points
ID: 34987850

if  you make a query tha will perform the selection you require on your contact table

 Then with a bttn on a form    using the  'on click'  event copy the line below into the code window

Docmd.TransferText acExportDelim" ,"queryName"," C;/ExportedContacts.csv"

Can  you can specify what the criteria for your selection is    this would help if you need further assistance



Expert Comment

ID: 34987962
Write a Macro choosing Action "TransferText". Or you can write VBA if you want more control 0n the code in a module like

sub exportdata()
DoCmd.TransferText TransferType:=acExportDelim, TableName:="YourQuery", FileName:="c:\YourFile.csv"
end sub

and call that exportdata function in a Macro.

Schedule the task (Macro) in the windows scheduler.

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

622 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