Hi, I need some help. The routine below runs when a command button is
clicked. A prompt appears to enter the directory path to the folder
containing delimited text files to be imported into an Access 97
table. The test folder contains 9 files. The problem is that the 1st file
is imported 9 times into the table. How do I correct the routine so it
loops properly and imports each file? Thanks in advance.
Gary
Private Sub Command0_Click()
Dim InputDir, ImportFile As String, tblName As String
Dim InputMsg, Name As String
InputMsg = "Type the pathname of the folder that contains "
InputMsg = InputMsg & "the files you want to import."
InputDir = InputBox(InputMsg)
' Change the file extension on the next line for the
' type of file you want to import.
ImportFile = Dir(InputDir & "\*.txt")
Name = ((InputDir) & ("\") & (ImportFile))
Do While Len(ImportFile) > 0
' Use the import file name without its extension as the table
' name.
tblName = "Expenses"
DoCmd.TransferText [acImportDelim], "Batch", "ExpBatch", Name
ImportFile = Dir
Loop
End Sub
Gary E. Daniels
Cornerstone Appraisal Company
500 Selkirk Drive
Schaumburg, IL. 60194
847 882-5892 Fax 847 882-5963
mailto:[EMAIL PROTECTED]
http://www.askdata.net
------------------------ Yahoo! Groups Sponsor --------------------~-->
Great things are happening at Yahoo! Groups. See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/q7folB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ms_access/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/