'make a list of all tables
Public Sub ListAllTbls()
Dim tdf As TableDef
Const kTBL = "tTables"
DoCmd.SetWarnings False
sSql = "SELECT 'start' AS TableName INTO tTables"
DoCmd.RunSQL sSql
sSql = "delete * from tTables"
DoCmd.RunSQL sSql
For Each tdf In CurrentDb.TableDefs
If InStr(tdf.Name, "~") > 0 Or InStr(tdf.Name, "msys") > 0 Then
'dont use system nor delete files
Else
sSql = "INSERT INTO " & kTBL & " ([TableName]) values ('" & tdf.Name & "')"
DoCmd.RunSQL sSql
End If
Next
DoCmd.OpenTable kTBL
DoCmd.SetWarnings True
Set tdf = Nothing
End Sub
'scan the table list and append their data to the master table
Public Sub ApdTblsInList()
Dim rst
Dim vTbl
Dim sSql As String
Set rst = CurrentDb.OpenRecordset("select * from tTables")
With rst
While Not .EOF
vTbl = .Fields(0).Value & ""
sSql = "insert into tMasterData SELECT * FROM " & vTbl
DoCmd.RunSQL sSql
Wend
End With
Set rst = Nothing
End Sub