you don't make like easy for yourself
I provided
strSQL = "INSERT INTO IT_Orig_Data (AllFields,FileName) " & _
" SELECT [F1] & [F2], '" & FieldName & "' FROM " & TableName
you used
StrSQL = "INSERT INTO IT_Orig_Data (AllFields,F2,FileName) " & _
" SELECT [F1], [F2], '" & FieldName & "' FROM " & TableName
with the comment 'the fields didn't concatenate'
your whole function could be simplified to
Code:
Function AppendTableData()
'Variable Declaration
Dim StrSQL As String
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) = "ZAPR" Then
'Run SQL Query (Insert)
StrSQL = "INSERT INTO IT_Orig_Data (AllFields, FileName) " & _
" SELECT [F1] & [F2], '" & tdf.SourceTableName & "' FROM " & tdf.Name
'Debug.Print StrSQL
db.Execute StrSQL
'msgbox db.recordsaffected & " records imported from " & tdf.name & " into IT_Orig_Data", vbOKonly
End If
Next
Set db = Nothing
End Function
note the proper declaration of variable types, use of indenting and use of code tags. The indenting shows that your 'Set db = Nothing' was in the wrong place (corrected above)
I don't understand why examples of F1 and F2 are needed.
it's taken 19 posts to get this far. Examples and other info was requested because your original post was very unclear - maybe not to you but to us who have no knowledge of your application. If examples had been provided (they don't have to be real, just realistic), together with the other information requested then this could been resolved in 2 or 3 posts. Example data, views of relationships and tables speak a lot more to us than a description of those things.
We give our time for free and we don't like wasting our time.