If statement in Conditional formatting

  • Thread starter Thread starter TotallyConfused
  • Start date Start date
T

TotallyConfused

If not how can I write an If expression in CF. For example "IF[field1] is
null and [field2] is null and if [field3] is null then "condition". Can
someone provide a sample? OR IF [field1] is not null and [field2] is not
null and [field3] is not null than current field should be greyed out.
Thank you.
 
You don't need an If statment. Select Expression is and use
IsNull(field1) And IsNull(field2) And IsNull(field3)
That would be one condition.
Add another condition with
Not IsNull(field1) And Not IsNull(field2) And Not IsNull(field3)
 
Thank you for your response. However, it doesn't work. This is what I have
for my conditions:

Not IsNull([field1]) OR NotIsNull([field2]) OR Not IsNull([field3])<>[due]

font is greyed out.

I want my date due to be greyed out if one of the other fields has a date
If not then due should be red. Can you help me with this. Thank you.

Klatuu said:
You don't need an If statment. Select Expression is and use
IsNull(field1) And IsNull(field2) And IsNull(field3)
That would be one condition.
Add another condition with
Not IsNull(field1) And Not IsNull(field2) And Not IsNull(field3)
--
Dave Hargis, Microsoft Access MVP


TotallyConfused said:
If not how can I write an If expression in CF. For example "IF[field1] is
null and [field2] is null and if [field3] is null then "condition". Can
someone provide a sample? OR IF [field1] is not null and [field2] is not
null and [field3] is not null than current field should be greyed out.
Thank you.
 
Totally,

Which control are you applying the Conditional Formatting to? From what
you say, I imagine it should be to the 'Due' control. You don't need to
try to incorporate a reference to that field into the CF expression, and
the way you have done it with <>[du] doesn't make sense to me. It is
not a good idea to use the IsNull function in these types of
expressions. Try it like this:

[field1] Is Not Null Or [field2] Is Not Null Or [field3] Is Not Null

.... substituting of course your actual field names for field1-3.
 
Thank you. This worked!! Thank you for this forum!!

Steve Schapel said:
Totally,

Which control are you applying the Conditional Formatting to? From what
you say, I imagine it should be to the 'Due' control. You don't need to
try to incorporate a reference to that field into the CF expression, and
the way you have done it with <>[du] doesn't make sense to me. It is
not a good idea to use the IsNull function in these types of
expressions. Try it like this:

[field1] Is Not Null Or [field2] Is Not Null Or [field3] Is Not Null

.... substituting of course your actual field names for field1-3.

--
Steve Schapel, Microsoft Access MVP
Thank you for your response. However, it doesn't work. This is what I have
for my conditions:

Not IsNull([field1]) OR NotIsNull([field2]) OR Not IsNull([field3])<>[due]

font is greyed out.

I want my date due to be greyed out if one of the other fields has a date
If not then due should be red. Can you help me with this. Thank you.
 
Back
Top