Looking for a way to match records querying 2 different tables

Shales

Board Regular
Joined
Aug 8, 2006
Messages
171
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have 2 tables that contain very similar data and I am trying to find matches.

For example, I have Surname1, Surname2, DOB1 & DOB2 coming from 2 separate tables. I am now after a 5th field in my query that that will give me a 1 if it can match either just the 2 surnames or just the DOB, and then a 2 if it matches both.

Hope this makes sense.

Regards
Gavin
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Might be worth adding that I have already joined the tables on Surname, so the count will always show at least a 1 based on my example. I have more fields I need to look for matches but I'll be able to figure that myself once I can obtain a working formula. Above is just an example of what i am working with.

Thanks
 
Upvote 0
Try along the lines of:

Join ....
ON
(
(Surname = Surname)
OR
(Dob = Dob)
)

The field you want will be able to populate with the logic:
((Surname = Surname) + (Dob = Dob)) As MyField

Since MSAccess treats true as the value -1 (negative one) you will get a -1 for one match and -2 for two matches. If you prefer positive numbers then just negate the result:
(((Surname = Surname) + (Dob = Dob)) * -1) As MyField

This is off the top of my head. If problems or if someone has a clearer answer please post again.
 
Upvote 0

Forum statistics

Threads
1,221,818
Messages
6,162,154
Members
451,749
Latest member
zack_ken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top