|
Question : Does "DoCmd.TransferSpreadsheet<wbr /> acImport" allow you to append records to an Access table ?
|
|
When using
DoCmd.TransferSpreadsheet acImport
into an Access database, is there a way to import the spreadsheets as additions to the existing records in a table as opposed to overwriting the table with totally new records (additions vs. inserts) ?
In other words could I loop through a series of spreadsheets and import them individually and append the records to an Access table.
Thus, if I have 5 spreadsheets with 20 records each, could I loop through the spreasheets using DoCmd.TransferSpreadsheet and accumulate 100 records in the table as a result of importing 5 separate spreasheets ?
|
|
Answer : Does "DoCmd.TransferSpreadsheet<wbr /> acImport" allow you to append records to an Access table ?
|
|
Part of the process implemented in the solution you were looking at was to have a table of files which had been previously imported, to prevent re-importing the same data. If you check the entire thread, you will see reference to that. If you are not trying to track imported filenames, then those parts of the code can be commented out.
Private Sub ConsolidateXLS() Dim myfile As String Dim str_sql As String myfile = Dir("c:\strip\branchest*.xls") Dim file_exist As Integer Do While myfile <> "" DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblExcelFiles", "c:\strip\" & myfile, True, "" DoCmd.RunSQL (str_sql) myfile = Dir Loop End Sub
if you are trying to track imported file names, you will have to create tblImportStatus.
|
|
|
|