Import then delete all *.tab files

B

BLTibbs

I have office 2000 and want to import all of the files in a directory that
end with *.tab into a table named 'AlibrisImportTable'. I have the code
below that is always giving me a run-time error 3011 stating it cannot find
the file (which is the first file in the directory), and no data is imported.

Can you please show me in my code where I have an error. I am not a
programmer. Thanks in advance.


Private Sub Command7_Click()
Dim strFile As String

strFile = Dir("c:\electroniclibrary\data\pendingalibris\*.tab")

Do While strFile <> ""
DoCmd.TransferText acImportDelim, , "AlibrisImportTable", strFile
Kill strFile
strFile = Dir
Loop

End Sub
 
D

Dirk Goldgar

BLTibbs said:
I have office 2000 and want to import all of the files in a directory
that end with *.tab into a table named 'AlibrisImportTable'. I have
the code below that is always giving me a run-time error 3011 stating
it cannot find the file (which is the first file in the directory),
and no data is imported.

Can you please show me in my code where I have an error. I am not a
programmer. Thanks in advance.

Answered in your previous thread.
 
G

Graham Mandeno

The Dir function returns only the filename part, not the full path, so
strFile will not be found.

Try this:

Dim strPath as String, strFile as String
strPath = "c:\electroniclibrary\data\pendingalibris\"
strFile = Dir( strPath & "*.tab" )
Do While strFile <> ""
DoCmd.TransferText acImportDelim, , "AlibrisImportTable", strPath &
strFile
Kill strPath & strFile
strFile = Dir
Loop
 
G

Graham Mandeno

Answered in your previous thread.

Grrrrrr! We crossed in the post, Dirk. I hate it when people do that!

Cheers,
Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top