J
John V
I use the code that follows (borrowed from a prior post) to import an
indeterminate number of text files (course evaluations) into a table for
further processing.
Unfortunately, the files' records contain no field that identifies the
course. Only the file name itself identifies the course.
So, is there a way to expand this procedure to insert and/or fill a field
with the filename as the value for every record in the file? Or is there some
other way to link the records to course names? Note I have no structural
control over the files themselves.
Second question, same process: How do I prompt the user to browse for the
folder containing the files?
Many thanks for your help.Function fimportAllFiles()
Dim strfile As String
Dim strPath As String
strPath = "DIRECTORY PATH"
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "Raw Data Import", "tblRawData",
strPath & "\" & strfile
strfile = Dir
Loop
End Function
indeterminate number of text files (course evaluations) into a table for
further processing.
Unfortunately, the files' records contain no field that identifies the
course. Only the file name itself identifies the course.
So, is there a way to expand this procedure to insert and/or fill a field
with the filename as the value for every record in the file? Or is there some
other way to link the records to course names? Note I have no structural
control over the files themselves.
Second question, same process: How do I prompt the user to browse for the
folder containing the files?
Many thanks for your help.Function fimportAllFiles()
Dim strfile As String
Dim strPath As String
strPath = "DIRECTORY PATH"
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "Raw Data Import", "tblRawData",
strPath & "\" & strfile
strfile = Dir
Loop
End Function