Add File Name to Table when Importing Files
Hello. I have a database which allows a user to import multiple .csv files at one time and adds them to a table. The file name format is based on the date and time including seconds which eliminates the possibility of duplicates since one person creates these throughout the day. Each file is considered a "batch" and can contain anywhere from 1 to 50 (or more) line items. If I can capture the file name and import that into the table that will allow me to show how many "batches" have been submitted.
Is there code that is compatible with what I am currently doing that will also import the filename into the table?
Operating System: Windows XP Professional
Program: Microsoft Access 2003
Example of .csv File Name: AROPS20111104145057.csv (AROPSYYYYMMDDHHMMSS.csv)
Here is the code I am currently using and it works wonderfully:
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Title = "Choose Files to Import"
.Filters.Add "Text Files", "*.csv"
If .Show = True Then
For Each varFile In .SelectedItems
DoCmd.TransferText acImportDelim, "AROPSImport", "tbl_AROPSImport", varFile
MsgBox "You have cancelled the import."
Any help you can provide would be greatly appreciated. Thank you.