G
Guest
I am working with 8 groups of 51 dbase files that are all in a trusted
location. My plan is to create one table per group, which means importing 408
dBase IV (I’m guessing the version) files as tables and appending 400 of the
tables to their respective 1st table. I’ve already imported the first two
files for each group to get the file structure and practice appending. I want
to do the rest in batch mode. I don’t know VBA or Access macros, though I
have worked with SPlus scripts & beaucoup dos batch files.
For the VBA, I found an example & have adapted it to import database data. I
first tried to work out the core of the macro, TransferData:
-------
Sub Import()
Dim dbs As Database
Set dbs = CurrentDb
DoCmd.TransferDatabase(acImport, "dBASE IV",
"C:\LSAY\Census\TabData\1990SF3\cd90_3A\vars01\", "stf305ar.dbf",,
"stf305ar", No)
End Sub
--------
My error messages are ‘compile error, syntax error’ and ‘compile error,
expected: =’. I don’t know what’s wrong. I must have left something out that
requires an ‘=’, but I don’t know what.
The macro is straightforward up to a point (have model sub-macro per group),
but … how do I expand each sub-macro to include the 48 other files? (or do I
have to create 400 more sub-groups?) Is there a way to append each file to
its base table within the same macro so that I don’t have to figure out how
to batch serial queries?
Here is the bulk import code (borrowed from Kirk, whose URL I didn’t keep).
Am I on the right track? Can I include an Append action in the same process?
(I don’t see anything about ‘append’ in the do.cmd list)
----------
Sub MassImport()
Dim strPath As String
Dim strTableName As String
Dim strFileName As String
Dim dbs As Database
Set dbs = CurrentDb
' Set the path to the directory where the files will be.
strPath = "C:\LSAY\Census\TabData\1990SF3\cd90_3A\vars01\"
strTableName = Dir(strPath) ' Retrieve the first entry table name.
strFileName = Dir(strPath & ".dbf") ' Retrieve the first entry file name.
Do While strFileName <> "" ' Start the loop.
DoCmd.TransferDatabase (acImport, "dBase IV", strPath,, strFileName,
strTableName, No)
strFileName = Dir ' Get next entry.
Loop
End Sub
-----------
location. My plan is to create one table per group, which means importing 408
dBase IV (I’m guessing the version) files as tables and appending 400 of the
tables to their respective 1st table. I’ve already imported the first two
files for each group to get the file structure and practice appending. I want
to do the rest in batch mode. I don’t know VBA or Access macros, though I
have worked with SPlus scripts & beaucoup dos batch files.
For the VBA, I found an example & have adapted it to import database data. I
first tried to work out the core of the macro, TransferData:
-------
Sub Import()
Dim dbs As Database
Set dbs = CurrentDb
DoCmd.TransferDatabase(acImport, "dBASE IV",
"C:\LSAY\Census\TabData\1990SF3\cd90_3A\vars01\", "stf305ar.dbf",,
"stf305ar", No)
End Sub
--------
My error messages are ‘compile error, syntax error’ and ‘compile error,
expected: =’. I don’t know what’s wrong. I must have left something out that
requires an ‘=’, but I don’t know what.
The macro is straightforward up to a point (have model sub-macro per group),
but … how do I expand each sub-macro to include the 48 other files? (or do I
have to create 400 more sub-groups?) Is there a way to append each file to
its base table within the same macro so that I don’t have to figure out how
to batch serial queries?
Here is the bulk import code (borrowed from Kirk, whose URL I didn’t keep).
Am I on the right track? Can I include an Append action in the same process?
(I don’t see anything about ‘append’ in the do.cmd list)
----------
Sub MassImport()
Dim strPath As String
Dim strTableName As String
Dim strFileName As String
Dim dbs As Database
Set dbs = CurrentDb
' Set the path to the directory where the files will be.
strPath = "C:\LSAY\Census\TabData\1990SF3\cd90_3A\vars01\"
strTableName = Dir(strPath) ' Retrieve the first entry table name.
strFileName = Dir(strPath & ".dbf") ' Retrieve the first entry file name.
Do While strFileName <> "" ' Start the loop.
DoCmd.TransferDatabase (acImport, "dBase IV", strPath,, strFileName,
strTableName, No)
strFileName = Dir ' Get next entry.
Loop
End Sub
-----------