Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I import all *.csv files in a directory with transfertext?

Status
Not open for further replies.

chrisbee

Technical User
Oct 13, 2001
67
GB
I have a database that is in three sites, I want to transfer information to and from sites via an FTP site, but how do I import ANY and ALL files that fulfil the naming criteria i.e. JER?????.csv
 
This is close to something we did. You will have to change directories accordingly, but it shouldn't take much to make it work.

==========

Public Sub ImportData()
On Error GoTo Err_Import
Dim strImportDir As String, strFile As String, strOldFile As String, strNewFile As String
strImportDir = "C:\Apps\Discovery\pmcp\"

Application.SetOption "Confirm Action Queries", False
strFile = Dir(strImportDir & "*.csv")

Do While strFile <> &quot;&quot; ' Start the loop.
strNewFile = strFile & &quot;.DUN&quot;
strOldFile = strFile

DoCmd.TransferText acImportFixed, &quot;Discovery Import Specs&quot;, &quot;tblTempDataDump&quot;, strOldFile
FileCopy strOldFile, strNewFile 'Copy file to new name
Kill strOldFile ' Delete Original txt File in &quot;PMCP&quot; Directory

DoEvents
strFile = Dir ' Get next entry.
Loop

Exit_Import:
On Error Resume Next
Application.SetOption &quot;Confirm Action Queries&quot;, True
Exit Sub

Err_Import:
MsgBox Err & Err.Description, , &quot;Error in Import&quot;
Resume Exit_Import
End Sub
========== Jim Lunde
compugeeks@hotmail.com
We all agree that your theory is crazy, but is it crazy enough?
 
I'll give it a go---hope it works for me..will let you know, thanx for the reply

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top