First off I'm a novice at programming.
Question I have built the code below from many examples off the internet. The database is named "Code Holder" at this time I have a table "test" and into that table I want append as many tables as there are in the database.
- All columns will be the same for all tables
- The table names other than "Test" will change
What I have so far is below, The code runs fine, but I can't seem to get each table to append into the "Test" table, each table comes up blank in the SQL string
Sub append4()
Dim db As Database
Dim tdf As TableDef
Dim rs As Recordset
Set db = currentdb()
Set rs = db.OpenRecordset("test")
For Each tdf In db.TableDefs
StrSQL = "INSERT INTO " & "test" & " " & _
"SELECT * " & _
"FROM " & "rs!tablename" & " ;"
DoCmd.RunSQL StrSQL
Next tdf
Set db = Nothing
End Sub
I want to say that I haven't set rs. correctly but I'm not certain. Any help would be appreciated.
Thanks
Afternoon, after posting I came across somthing that really helped. Below is the updated VBA code and after testing it works for me.
Thanks Barett, yes I was referencing a table incorrectly, but that's what happens when you stare at somthing for way too long.
Feel free to copy and use if you'd like