Hi list,

After creating a rs with UNION ALL two tables it's possible know record by
record the original table source (using any extra SQL feature or something
else)

SQL = "SELECT * FROM tabA UNION ALL SELECT * FROM tabB ORDER BY field"
Set rs = db.OpenRecordset(SQL)

Thanks
Fernando

I don't know what you really mean but if you mean that to look in a PER record I think you do the loop statement.
ie.

SQL = "SELECT * FROM tabA UNION ALL SELECT * FROM tabB ORDER BY field"
Set rs = db.OpenRecordset(SQL)

IF NOT rs.EOF THEN
    DO WHILE NOT rs.EOF
            Text1.Text=rs!Fieldname1
            Text2.Text=rs!Fieldname2
     LOOP
END IF

Hi,

Try this :

SQL = "SELECT 'MyTableA' As TabName, A.* FROM tabA A UNION ALL SELECT 'MyTableB' As TabName, B.* FROM tabB B ORDER BY field"
Set rs = db.OpenRecordset(SQL)

RS("TabName") Gives you the Table Name

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.