automatically Import all *.tab files

B

BLTibbs

I have a folder that receives files from an automatic download throughout the
day. Each file is uniquely named but all end with *.tab. I am using Access
2000 on a windows xp computer.

I am not a programmer, but is there some code that I can cut and paste into
a command button to import into an access table and delete all files in a
specific folder that fit the *.tab criteria?
 
R

Ron Hinds

BLTibbs said:
I have a folder that receives files from an automatic download throughout the
day. Each file is uniquely named but all end with *.tab. I am using Access
2000 on a windows xp computer.

I am not a programmer, but is there some code that I can cut and paste into
a command button to import into an access table and delete all files in a
specific folder that fit the *.tab criteria?

Yes. But it won't work without some modification. Hopefully you can figure
out where ;-)

Private Sub Command1_Click
Dim strFile As String

strFile = Dir("*.tab")

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

End Sub
 
B

BLTibbs

Below is the code I have in my system (thanks!) but I always get an MS jet
engine error stating that it cannot find the first file in the list and no
data gets imported. What am I missing?

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:
Below is the code I have in my system (thanks!) but I always get an
MS jet engine error stating that it cannot find the first file in the
list and no data gets imported. What am I missing?

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

Dir() will return only the filename (with extension), but TransferText
will also need to know the folder path. Try this:

'----- start of code -----
Private Sub Command7_Click()

Dim strFile As String

Const conFolder As String =
"c:\electroniclibrary\data\pendingalibris\"

strFile = Dir(conFolder & "*.tab")

Do While strFile <> ""

DoCmd.TransferText acImportDelim, , "AlibrisImportTable", _
conFolder & strFile

Kill strFile

strFile = Dir

Loop

End Sub

'----- end of code -----
 
Top