Yes you can combine more than two tables.
You can't do it with a parameter. Parameters are for criteria only.
IF I needed to do this I would probably write a vba routine and pass it the
names of the tables to be unioned. Then the VBA could build the SQL statement
and then you could use that to set the SQL of a query. It would require that
you have the same field names in each list, but since you are extracting them
from the same source, I would think it wouldn't be a problem
UNTESTED AIR CODE for building the SQL String; You can use the string to build
a query def, populate a recordset, etc.
Public Function MakeSQL (ParamArray aTableNames()) As String
Dim I as Integer, strSQL As String
For I = LBound(aTableNames) to UBound(aTableNames)
StrSQL = StrSQL & "SELECT NameField, AddressField" & _
", CityField, StateField, ZipCode" & _
"FROM " & aTableNames(I) & " UNION "
Next I
If Len(StrSQL) > 0 Then
StrSQL = Left(StrSQL,Len(StrSQL)-7)
End If
MakeSQL = StrSQL
End Function
Thanks John. Our lists are extracts from our exchange server, so we could
avoid problems by re-extracting the lists each time we run labels or do a
mail merge. Can we use the union merge to merge more than two tables in one
pass? How do we write the query to prompt for the table names, or give a
drop down list to the user? I've seen how to prompt for parameters in the
query grid, but not in SQL code.
--