[AccessD] Importing multiple txt files

Mark A Matte markamatte at hotmail.com
Wed Apr 1 12:21:58 CDT 2009



This may help...
 
Public Function ImportData()
MyPath = "C:\Stock\BriterStockBiHourlyTEMP\*.csv"
MyName = Dir(MyPath)   ' Retrieve the first entry.
DoCmd.SetWarnings False
Do While MyName <> ""   ' Start the loop.
DoCmd.TransferText acImportDelim, "MyImportSpecification", "tblDailyStock", "C:\Stock\BriterStockBiHourlyTEMP\" & MyName
 
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
    MyName = Dir    ' Get next entry.
    End If
Loop
 
End Function
 
Hope it helps...
 
Mark A. Matte
----------------------------------------
> Date: Wed, 1 Apr 2009 12:12:07 -0500
> From: jerbach at gmail.com
> To: accessd at databaseadvisors.com
> Subject: [AccessD] Importing multiple txt files
>
> Hello!
>
> I would like to programmatically import one by one all the text files in a
> given directory - usually around 30 files. I've used code that I copied
> from http://www.mvps.org/access/api/api0001.htm to allow the user to browse
> through windows directories and select a single file to process...but now I
> want to process ALL the files in a given directory, regardless of the number
> of files. I assumed I would build an array with the names of all the files
> and then loop through that array in my code to import and process them one
> by one.
>
> Does anyone know of code I could utilize that would allow me to identifity
> the names of all the txt files in a selected directory? I'm lost when it
> comes to interfacing Access with Windows in this way!
>
> Janet Erbach
> NaturalHealthyConcepts.com
_________________________________________________________________
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile1_042009



More information about the AccessD mailing list