# Lookup for amount payable if conditions met or not

• ### Question

• I am trying to create table 3 by querying data from two other tables.

I would be grateful if anyone can point me in the right direction. I have been going round in circles rewriting code and I can't see the wood for the trees now.

**Table 1**
Payee Referrer,
Accident Type,
Expert Type,
Amount

**Table 2**
Case No
Payee Referrer
Accident Type
Expert Type

**Create Table 3 on the basis of this logic**

Select Case No from Table 2 AND Amount from Table 1

IF   Payee Referrer (Table 2) = Payee referrer (Table 1)
AND    Accident Type and Expert Type (Table 2) = Accident Type and Expert Type (Table 1)
OR   Payee Referrer (Table 2) = Payee referrer (Table 1)
AND  Accident Type (table 2) = Accident Type (Table 1)
OR   Payee Referrer (Table 2) = Payee referrer (Table 1)
AND  Expert Type (table 2) = Expert Type (Table 1)

IF    None of the above combinations exist then
get the Amount (Table 1) where Accident Type and Expert Type (Table 1) = 'DEFUALT'
Tuesday, November 24, 2020 11:57 AM