Solved

Access VBA  Loop through csv files in a folder and import using an import specification

Posted on 2014-10-20
2
3,704 Views
Last Modified: 2014-10-21
Hi

What Access VBA code would I use to loop through csv files in a folder and import using an import specification?
0
Comment
Question by:murbro
2 Comments
 
LVL 7

Accepted Solution

by:
slubek earned 500 total points
ID: 40393678
I'm using something like that:
Public Const rootdir = "c:\Data\"

Sub import()
    Dim nr as int
    file = Dir$(rootdir & "*.csv")
    nr = 1
    Do While file <> ""
	DoCmd.TransferText acImportDelim, "ImportSpec", "NewTableName-" & nr, rootdir & file, True, , msoencodingCentralEuropean
	file = Dir$
	nr = nr + 1
    Loop
End Sub

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 40394226
Thanks
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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

803 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