I am trying to get an Access report to identify if a text field (NH) does not match with the same ID. For example, ID 179 has two rows but each NH is different (12345 & 12346). I am trying to use DCount to count the IDs where the NH does not match if it is the same ID but I cannot figure it out.
Here is an example of my code: This is supposed to get the ID's that match such as 179 and 179 and check the NH to see if the are the same and return a count if they are not.
CheckValue = DCount([ID], "vTestQuery", "[NH] <> '" & [NH] & "'" And "[ID] ='" & [ID] & "'")
This gives a value to Me.txtColor for a Conditional formatting I have set up if CheckValue has an actual value.
If (CheckValue > 0) Then
Me.txtColor = CheckValue
I also need this go through all the records in the report and get a count on each matching ID with different NHs so I can flag the NHs that are different.
Can someone let me know if I am even on the right track with this and if so a solution to my dilemma.
Thank you very much!
1st EDIT
Sample Data:
+-----+------------+------------+------------+-------------+
| ID | FullName | DateOfServ | AccountNum | NoteH |
+-----+------------+------------+------------+-------------+
| 179 | Test, Jane | 8/1/2015 | 458585 | AAA-1111111 |
| 180 | Test, Paul | 8/1/2015 | 458586 | AAA-2222222 |
| 181 | Test, John | 8/2/2015 | 458587 | AAA-3333333 |
| 214 | Test, Alex | 8/3/2015 | 458588 | AAA-4444444 |
| 214 | Test, Alex | 8/3/2015 | 458588 | AAA-4444445 |
| 215 | Test, Alex | 8/3/2015 | 458589 | AAA-5555555 |
| 215 | Test, Alex | 8/3/2015 | 458589 | AAA-5555555 |
+-----+------------+------------+------------+-------------+
So what I need the report to do is highlight or change text color for the IDs that match but have a different NH For example record 214 has two records with all the same exact data except for the NoteH and I need both those NoteH to be highlighted or the text changed. I have made the NoteH in question both bold. Let me know if this helps.
2nd EDIT
So the query worked for all duplicate IDs with duplicate NoteH, but it still only registers one ID if the NoteH is different. I added an IDCount to show how the query registers each 214 ID as different because of the different NoteH.
Here are the results:
+-----+------------+---------+
| ID | NoteCount | IDCount |
+-----+------------+---------+
| 214 | 1 | 1 |
+-----+------------+---------+
| 214 | 1 | 1 |
+-----+------------+---------+
| 212 | 2 | 2 |
+-----+------------+---------+
I need a way to have the report recognize that 214 is a duplicate field but the NoteH is not the same. It is really close to working everything else you suggested works great!!!
3rd EDIT
SELECT May.ID, Count(May.ID) AS IDCount, FROM May INNER JOIN
Count(CodeRyteCodingResults.[Note Handle]) AS NoteCount
CodeRyteCodingResults ON May.[Accession #] =
CodeRyteCodingResults.[Accession Number]
GROUP BY May.ID;