automated import txt files

  • Thread starter Linde via AccessMonster.com
  • Start date
L

Linde via AccessMonster.com

Hi,

I used the procedure described below to automatically import text files,
using a defined import specification.
Public Function Import()
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("*.txt")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName", _
"AccessTableName", "c:\MyFiles\" & strfile, True
Kill "c:\MyFiles\" & strfile
strfile = Dir()
Loop
End Function

This all works great on one condition:
After opening the database, I first have to import one text file manually,
using the same import specification. If I don't do that, no data is imported -

no error messages appear.
After this first manual import, it all works well.

Does anyone have an idea how to solve this inefficiency?

Thanks in advance,

Linde
 

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