Conditional formatting

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

I have a form to which I want to apply conditional formatting to a control
based on the value in another control on the same form. I tried to use the
following:

IIF(ME!OtherControl<Now(), True, False)

for the 'Expression Is' condition for the control's conditional formatting.
That does not work and I have not been able to get it to work using
variations of the expression.

What am I doing wrong?

Thanks
 
What you are trying to do is not 'conditional formatting', which allows you
to change how a value is displayed (forecolor, backcolor, bold, italics,
underlined, etc.). Your expression is trying to change the *value* of a
control. One of the ways you can use this in a form is to put an expression
in the OnCurrent event of a form:

If Me!OtherControl < Now() then
Me!ThisControl = True
Else
Me!ThisControl = False
End If
 
Change the color of the displayed value is what I want to do. i.e. when
me!OtherControl < Now(), I want Me!ThisControl to be another color.
 
After right-clicking on ThisControl and selecting Conditional Formatting,
select "Expression is" from the combo box and insert:

ME!OtherControl<Now()

and select your color.
 
I've tried that as well but for some reason it does not work. I'm really
puzzled because it seems that it should be really simple.
 
Chuck,

When you say "does not work", do you mean that you get an error message? If
so, what is it? Or, do you mean that the field does not format as you
would expect? Tell us more about the kind of data that is in this field
and what the condition (comparison to Now()) is intended to show.
 
It does not format as expected.

I have a form with several controls. The form is in datasheet view (but it
does not format in form view either). I have one control with a "Date"
record source. I have other controls of various data types. If the date in
the date control is < Now(), I want all the other controls for that record
to change color as well.

If I use the same syntax I have been using in this post, here is what I am
doing:

For Me!OtherControl, the conditional formatting is "Field value less than
now()" format in red
For Me!ThisControl, the conditional formatting is "Expression is
ME!OtherControl<Now()" format in red

Me!OtherControl is the only control that changes color when the condition
is met.

Thanks
 
Chuck,

Access' built-in conditional formatting is applied to a specific control -
not all controls. May I suggest having a look at MVP Stephen Lebans'
web-site, specifically the following link:

http://www.lebans.com/conditionalformatting.htm

Stephen has expanded Access' existing capabilities in this area (and many
others) and I believe you'll find what you want there.
 
actually, I plan on doing the conditional formatting on all the controls. I
realise that it applies to a specific control and not all of them. What I
don't understand is why it does not work. It really does seem simple
enough! Very frustrating!

I am aware of Stephen's site and have used it before. His conditional
database is very nice but deems to be overkill for what I want. I guess
I'll give it a try though.

Thanks anyways.

Chuck
 
Finally got it to work. In the conditional formatting expresion, I had to
use the name of the field instead of referencing the control.

i.e.: instead of using Me!OtherControl<Now() I had to use
[OtherControl]<Now() where OtherControl is the control source of the
Me!OtherControl control. I also had to enclose it in square brackets.
 
Back
Top