Apply formatting to highlight duplicated names in query output?

HGCanada

Registered User.
Local time
Today, 01:05
Joined
Dec 30, 2016
Messages
82
I have a query that pulls together data from several sub-queries. One of the sub-queries may occasionally result in multiple records for the same person. At this point, we are not changing the database to prevent this. We do not want to prevent duplicate records - we need to see the duplicates. However, I would like to at least highlight duplicated names, to alert the users. How can I do this?

I've attached a picture of query output with fake names, and an example of two records for one person. I'd love to make the first and last name red, if it's duplicated. (In my picture, the rows are highlighted only because I've selected those rows by mouse.)
 

Attachments

  • Duplicate in query output.jpg
    Duplicate in query output.jpg
    49.3 KB · Views: 130
**
Firstly, you must add an Expression in your
query that will Count the number of PTCaseID or by
[LastName] & [FirstName].

CountOfPTCaseID: (SELECT Count(*) From YourTableWithPTCaseID AS T1 WHERE T1.PTCaseID = YourTableWithPTCaseID)

or

CountOfPTCaseID: (SELECT Count(*) From YourTableWithPTCaseID AS T1 WHERE T1.[FirstName] & T1.[LastName] = YourTableWithPTCaseID.[FirstName] & YourTableWithPTCaseID.[LastName])


**
next you need to put your Query in a Form (datasheet or continuous form).
while still in form design view, select all your TextBoxes.
on the Ribbon, Format->Conditional Formatting, create New Rule.

Expression Is [CountOfPTCaseID] > 1

select the background color of your choice.
 

Users who are viewing this thread

Back
Top Bottom