Join by field name?

J

Jason Gyetko

Is it possible to join by a field name instead of the value? I have two
tables which I need to retrieve all records for each table where the field
names are equal (and leave out the fields that don't match up).

Ex: TableA.Field1 = TableB.Field1

TableA TableB
-------- -------
Field1 = Data1 Field1 = Data100
Field2 = Data2 Field2 = Data200
Field4 = Data4 Field3 = Data300
Field4 = Data400

I do NOT want to show TableB.Field3 in my query results. Any help would be
greatly appreciated. Thanks.
 
J

John Spencer (MVP)

Not in a query without writing the query in using VBA. If you were using DAO,
you could loop through the field names and match the fields up. Then you could
put the fields in the Select clause.

This looks like a highly unusual thing to do. Also, you need to look at what
results you would get with two tables (especially if you didn't have any joins).
 
J

Jason Gyetko

Thanks for the reply. We were able to restructure our tables so we don't
need to do it this way anymore.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top