adammitchell23
Registered User.
- Local time
- Today, 10:59
- Joined
- Oct 30, 2017
- Messages
- 24
Hi Folks,
I'm attempting to import multiple tab-delimited .txt files into a table in my database. The files are then deleted (manually) and the folder gradually repopulates over time (one a day) with new files produced automatically by a weather monitoring station. I'm using the following to do this:
Where the directory of the .txt file is "Z:\Monitoring\AWS_Import" and the table to which they're being appended is "tblWeatherImportTemp".
This works when I set up an import specification ("ImportWeather") and then run the function but if I attempt to then run the code based on that specification at a later date it won't work. I receive the error "Could not locate file "xxxxx.txt"".
This makes sense if I deleted the file with which I'm creating the import specification, but the error even occurs if I use a blank file as an 'anchor' for the specification to latch on to each time. If I go back and remake the specification using exactly the same criteria, it works again, but again, works only that one time.
Hopefully that makes sense...
Can someone help me out?
Cheers,
Ad
I'm attempting to import multiple tab-delimited .txt files into a table in my database. The files are then deleted (manually) and the folder gradually repopulates over time (one a day) with new files produced automatically by a weather monitoring station. I'm using the following to do this:
Code:
Function ImportWeather()
Dim fileName As String
fileName = Dir("Z:\Monitoring\AWS_Import" & "\*.txt")
While fileName <> ""
DoCmd.TransferText acImportDelim, "ImportWeather", "tblWeatherImportTemp", fileName, True
fileName = Dir()
Wend
End Function
Where the directory of the .txt file is "Z:\Monitoring\AWS_Import" and the table to which they're being appended is "tblWeatherImportTemp".
This works when I set up an import specification ("ImportWeather") and then run the function but if I attempt to then run the code based on that specification at a later date it won't work. I receive the error "Could not locate file "xxxxx.txt"".
This makes sense if I deleted the file with which I'm creating the import specification, but the error even occurs if I use a blank file as an 'anchor' for the specification to latch on to each time. If I go back and remake the specification using exactly the same criteria, it works again, but again, works only that one time.
Hopefully that makes sense...
Can someone help me out?
Cheers,
Ad