Solved

Ms Access script to export csv file

Posted on 2011-02-26
3
501 Views
Last Modified: 2012-05-11
Hi,

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

Regards
Leigh
0
Comment
Question by:Lmillard
3 Comments
 

Expert Comment

by:plshrk
ID: 34987839
Yes this is possible, would you provide some additional details, please.
0
 
LVL 2

Accepted Solution

by:
jo_m earned 500 total points
ID: 34987850
hello

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

t

 jo
0
 
LVL 4

Expert Comment

by:tabish
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.
 
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tags from access to excel 3 24
Open CSV, modify and save as xls from Access 12 19
How can I create a table in a linked database, in VB? 7 17
Is it possible to reset DSum? 12 40
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

947 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

21 Experts available now in Live!

Get 1:1 Help Now