VB Code to Automatically link CSV files located in a folder

Access nubie

Registered User.
Local time
Today, 17:58
Joined
Oct 24, 2008
Messages
14
This is needed in anticipation of rolling our dept to access 2013 which does not support linked DBF files. end users have their own various databases that they have created with a number of tables linked to various DBF files (located in d:\data). The DBF files are downloaded every week due to updated data. we have a process to convert the downloaded DBF files to CSV files & remove the linked DBF tables from the database. Now we need to develop a one-time process which will link the the CSV files (also in D:\DATA). However, we ONLY want to link the filenames that are contained in a table (tblTableNames) in the database.
Below is code that worked beautifully to link *all* of the CSV files in d:\data. but again, we ONLY want to link to the CSV files that are listed in the table tblTableNames. any help tweaking the code or providing new code would be greatly appreciated.
Dim strFile As String
Dim strPath As String
Dim strTable As String

strPath = "D:\Data\"
strFile = Dir(strPath & "*.csv")
Do While Len(strFile) > 0
strTable = Left$(strFile, Len(strFile) - 4)
DoCmd.TransferText acLinkDelim, TableName:=strTable, _
FileName:=strPath & strFile, HasFieldNames:=True
strFile = Dir()
Loop
End Sub
 

Users who are viewing this thread

Back
Top Bottom