Hi,
I'm trying to get MS Access 2000 to automatically import a series of
(~200) flat text, tab delimited, data files into a single Access table,
with consistent fields and rows.
The files have different, but somewhat logical naming structures
(ex.Jun01.txt, Jun02.txt, Jul01.txt, etc...).
Is there a relatively simple way to accomplish this, considering i'm new
to Access. I was especially hoping to do this without having to
manually create new import specs or type in file names for each new data
file i need to import. With 200-300 files, that can get tedious.
I tried the following code i found on the internet (listed below) which
i created as a module and then run it under a Macro with the OpenModule
action. But i keep getting error message which says that i'm invoking an
invalid outside procedure.
Thanks for any help !
Code:
Dim objAccess
Dim strPathToMDB
Dim sTable
Dim sFilePath
Const acImportDelim = 0
' // NOTE: User must edit variables in this section //
'
' The following 3 lines of code are the only variables
' that need be edited
' Provide paths to the Access MDB, Text file for import
' and the new table name.
'
strPathToMDB = "C:\DbTest.mdb"
sFilePath = "C:\Attachments.txt"
sTable = "Attach"
'
' /////////////////////////////////////////////////////
' Create Access 97 Application Object
Set objAccess = CreateObject("Access.Application.8")
' For Access 2000, use Application.9
'Set objAccess = CreateObject("Access.Application.9")
' Open the desired database
objAccess.OpenCurrentDatabase(strPathToMDB)
' Use the TransferText command to import the file
' (with Column Heads)
objAccess.DoCmd.TransferText acImportDelim,,sTable,sFilePath,True
' Clean up
Set objAccess = Nothing
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!