G
Guest
Hi All
I'm importing a text file into a table. The code below works great. However, it is possible to import the wrong text file (ie., a file which should be imported into another table, with different columns etc. Is there anyway to specify to check column heading of the import file with the table or something
You can see I've added an InStr function which checks the file name for the right text as a way around it.. but its not really sufficient
If myFile <> "" The
If InStr(1, myFile, MyText, vbTextCompare) > 0 Then '<the text was found
DoCmd.TransferText acImportDelim, mySpec, myTable, myFile, True, "
MsgBox "File uploaded: " & myFile & Chr(13) & " to Table : '" & myTable & "'.
Else '<it wasn't
MsgBox "File : " & myFile & Chr(13) &
"Not uploaded. Are you sure this is the right file? The file must have the text : '" & MyText & "'."
End I
Where
myFile = file name and directory for uploading into tabl
myTable = table name that myFile is uploaded int
mySpec = is specification name for importation into tabl
myText = additional check, to see if the file has the right name in it (see comments above
Thanks
Marcu
I'm importing a text file into a table. The code below works great. However, it is possible to import the wrong text file (ie., a file which should be imported into another table, with different columns etc. Is there anyway to specify to check column heading of the import file with the table or something
You can see I've added an InStr function which checks the file name for the right text as a way around it.. but its not really sufficient
If myFile <> "" The
If InStr(1, myFile, MyText, vbTextCompare) > 0 Then '<the text was found
DoCmd.TransferText acImportDelim, mySpec, myTable, myFile, True, "
MsgBox "File uploaded: " & myFile & Chr(13) & " to Table : '" & myTable & "'.
Else '<it wasn't
MsgBox "File : " & myFile & Chr(13) &
"Not uploaded. Are you sure this is the right file? The file must have the text : '" & MyText & "'."
End I
Where
myFile = file name and directory for uploading into tabl
myTable = table name that myFile is uploaded int
mySpec = is specification name for importation into tabl
myText = additional check, to see if the file has the right name in it (see comments above
Thanks
Marcu