In my Access database I have a table (dbo_000_DataCubeProcessing) which contains a list of tables that I need to export to Excel on a regular basis along with a checkbox for each. Once I select the relevant table via checkbox, I have VBA code written which will pick this table and can export to a pre-defined location on my network in Excel format. I was wondering if there exists code (e.g. some type of Loop procedure) whereby I can select multiple tables via this checkbox and the VBA code can export all of these at once?
This would be very useful as there are occasions where I to export 10-15 tables at the same time and would like to perform it in one VBA procedure instead of re-running each time
My current code is:
Expand|Select|Wrap|Line Numbers
- Sub ExportTable()
- 'Define Variables
- SelectTableToExport = DLookup("[Table]", "dbo_000_DataCubeProcessing", "[Select] = True")
- TableSaveName = DLookup("[ExportFileName]", "dbo_000_DataCubeProcessing", "[Select] = True")
- 'Export file to network
- DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, SelectTableToExport, "H:\" & TableSaveName, True
- 'Reset Table
- DoCmd.SetWarnings False
- DoCmd.RunSQL "UPDATE Dbo_000_DataCubeProcessing SET [Select]=No"
- DoCmd.SetWarnings True
- End Sub
Dan