I have a situation where I have clients, and each client has two brokers. I have a client table (showing the client ID, client name, address etc, ID# of their first broker, and ID# of their 2nd broker). I also have a Broker table, with a Broker ID as the key ,and then info about that broker (name, address).
Example:
ClientTable:
<tbody>
</tbody>
Where BrID1 and BrID2 are the ID numbers of the Client's two brokers.
BrokerTable:
<tbody>
</tbody>
I'm trying to generate a query where I list each of the two brokers for each client.
Desired Query Output:
<tbody>
</tbody>
I can do this in a report, using the DLookup function to pull the names of the brokers out of the broker table (the report pulls from a query generated only by the Client table).
I feel like I should be able to use the DLookup function in a query to do the same thing, but I can't make it work.
I don't think I can do a "normal" query where I link the two tables and pull from the combination, because there would need to be two links between the tables linking two separate fields in the Client table with the same link on the BrokerTable - one between [ClientTable]![BrID1] and [BrokerTable]![BrokerID] and one between [ClientTable]![BrID2] and [BrokerTable]![BrokerID]. I'm not aware that I can do such a V-shaped link, and I get error messages when I try.
If using the Dlookup function in a query is the best way to do it, what is the syntax? Do I include the BrokerTable in the "FROM" section of the query, and, if so, with what kind of link?
This example is, of course, simplified, but the real data isn't that large - I'm not concerned with a DLookup function slowing down the performance of the query running.
Thanks.
Example:
ClientTable:
Client ID | Client Name | BrID1 | BrID2 |
123 | FirstClient | A | B |
456 | SecondClient | B | C |
<tbody>
</tbody>
Where BrID1 and BrID2 are the ID numbers of the Client's two brokers.
BrokerTable:
BrokerID | Broker Name | Broker's Address |
A | Smith | Main St |
B | Jones | Elm St |
C | Brown | Washington St |
<tbody>
</tbody>
I'm trying to generate a query where I list each of the two brokers for each client.
Desired Query Output:
Client ID | Client Name | Name of Client's First Broker | Name of Client's 2nd Broker |
123 | FirstClient | Smith | Jones |
456 | SecondClient | Jones | Brown |
<tbody>
</tbody>
I can do this in a report, using the DLookup function to pull the names of the brokers out of the broker table (the report pulls from a query generated only by the Client table).
I feel like I should be able to use the DLookup function in a query to do the same thing, but I can't make it work.
I don't think I can do a "normal" query where I link the two tables and pull from the combination, because there would need to be two links between the tables linking two separate fields in the Client table with the same link on the BrokerTable - one between [ClientTable]![BrID1] and [BrokerTable]![BrokerID] and one between [ClientTable]![BrID2] and [BrokerTable]![BrokerID]. I'm not aware that I can do such a V-shaped link, and I get error messages when I try.
If using the Dlookup function in a query is the best way to do it, what is the syntax? Do I include the BrokerTable in the "FROM" section of the query, and, if so, with what kind of link?
This example is, of course, simplified, but the real data isn't that large - I'm not concerned with a DLookup function slowing down the performance of the query running.
Thanks.