Conditional Formatting Continuous Form based on 2 fields (1 Viewer)

Danick

Registered User.
Local time
Today, 13:20
Joined
Sep 23, 2008
Messages
351
I'm trying to highlight a field with duplicate values in a continuous form but only when that field and another field are different.
I've tried various combinations of the following code, but can't get it work
Code:
DCount("*","TableName","[SN]='" & [txtSN] & "' AND [ID]<>" & [ID])>0

This is what it's supposed to look like in the end.

2022-11-01 SC.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:20
Joined
Sep 21, 2011
Messages
14,373
How is Access meant to know which ID you are talking about?
To me it looks like you are comparing the field ID with the fieldID, which of course would always be the same?

You differentiate for SN and txtSN, why not the form control ID ?
 

Danick

Registered User.
Local time
Today, 13:20
Joined
Sep 23, 2008
Messages
351
How is Access meant to know which ID you are talking about?

Yes this is the problem. I can't figure out how Access can differentiate these fields.
Basically, it should look at all SNs that are identical and then only highlight SNs that have different IDs.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:20
Joined
Sep 21, 2011
Messages
14,373
What is the ID meant to be for those ABC's that you are checking?
Why can't you use txtID as you did for SN?
 

Danick

Registered User.
Local time
Today, 13:20
Joined
Sep 23, 2008
Messages
351
What is the ID meant to be for those ABC's that you are checking?
Why can't you use txtID as you did for SN?
I picked an ID field that repeats itself for simplicity. But it could very well be a PO number or a Received Date field.
There will be many records of a SN that came in on a Received date. So I don't need to highlight any of those SNs.
However, it that SN is repeated on a different received date, then I'd like to highlight those SNs.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:20
Joined
Sep 21, 2011
Messages
14,373
You still need to compare against the form control value though, surely?
Regardless of what field you use?
 

Users who are viewing this thread

Top Bottom