D
Daniel
The below codes appends tables that all have the word
attendances in the name, but the fields it appends to
the target table have spaces in the names, since there
are lots of tables I don't want to go into design view to
change them. How do I amend the code to cope with spaces
in field names.
Sub Append_Tables()
TargetTable = "ALLData"
For Each tbl In CurrentDb.TableDefs
If Right(tbl.Name, 11) = "Attendances" Then
sourcetable = tbl.Name
strsql = "INSERT INTO " & TargetTable _
& " SELECT provider,arrival date, tel No._
& " FROM [" & sourcetable & "]"
'& " WHERE ep = 1"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
End If
Next
End Sub
attendances in the name, but the fields it appends to
the target table have spaces in the names, since there
are lots of tables I don't want to go into design view to
change them. How do I amend the code to cope with spaces
in field names.
Sub Append_Tables()
TargetTable = "ALLData"
For Each tbl In CurrentDb.TableDefs
If Right(tbl.Name, 11) = "Attendances" Then
sourcetable = tbl.Name
strsql = "INSERT INTO " & TargetTable _
& " SELECT provider,arrival date, tel No._
& " FROM [" & sourcetable & "]"
'& " WHERE ep = 1"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
End If
Next
End Sub