Solved

Ms Access script to export csv file

Posted on 2011-02-26
3
523 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
[X]
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
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 VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

756 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