Continuous Forms Formatting

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi,

I see a lot of posts about conditional formatting, but I'm not sure it can
handle what I am trying to do:

1. Field A is a date field. I want to do the following if Field A is
between 1/1/2007 and 12/31/2007
a. Check a check box and lock that check box after it is checked
b. Locked a bound text field
ELSE
a. Unlock the check box, allowing the user the option of checking it
b. Unlock the bound text field
c. Make the background of the text field pale yellow.

Can I do this with Conditional formatting, and if so, how?

Thanks.

--David
 
No, what you are describing is not formatting.
It will take some VBA code to accomplish this. I would suggest using the
form current event:

Dim blnLock as Boolean

blnLock = Me.FieldA >= #1/1/2007# And <= #12/31/2007# Then
Me.MyCheckBox = blnLock
Me.MyCheckBox.Locked = blnLock
Me.MyCheckBox.Enabled = Not blnLock
Me.MyTextControl.Locked = blnLock
Me.MyTextControl.Enabled = Not blnLock

If Not blnLock Then
Me.MyTextControl.BackColor = 8454143
Else
Me.MyTextControl.BackColor = 16777215
End If
 
Hi -

Conditional formatting only changes the display properties of controls, so it
is not what you need here.

What you can do is put code in the On Current event of the form to make the
changes you require, something like this:

if me![Field A] >= #01-01-2007# and me![Field A] <= #12-31-2007# then
me![checkbox1] = true
me![checkbox1].locked=true
me![Field1].locked=true
me![field1].backcolor=16777215
else
me![checkbox1].locked=false
me![Field1].locked=false
me![field1].backcolor=8454143
endif

Depending on your requirements, you may want some additional code in the
After Update events of the checkbox and the text box.

HTH

John
 
David said:
I see a lot of posts about conditional formatting, but I'm not sure it can
handle what I am trying to do:

1. Field A is a date field. I want to do the following if Field A is
between 1/1/2007 and 12/31/2007
a. Check a check box and lock that check box after it is checked
b. Locked a bound text field
ELSE
a. Unlock the check box, allowing the user the option of checking it
b. Unlock the bound text field
c. Make the background of the text field pale yellow.

Can I do this with Conditional formatting, and if so, how?


On a continuous or datasheet form, you need to use CF for
the color. But you have to use code like the others posted
to lock the controls/
 
Thanks all.

One question on the Conditional Formatting then.

How do I set a condition on a field (the color in this case), while
referring to another field to determine what color to make it?

In this case, If Field A is between 1/1 and 12/31, make Field B white, else,
make Field B yellow?
 
Hi,

I had tried that, but found that the ON CURRENT event only fires at sporadic
time, not for each record read/presented. For example, it fires on the first
record. If I page down, it does not fire again until I select a record, then
it fires and evaluates the field in question in order to take some action.

A way to test this is to put a break point in the code. It only breaks in
the situations I described above.

Thanks.
 
David said:
One question on the Conditional Formatting then.

How do I set a condition on a field (the color in this case), while
referring to another field to determine what color to make it?

In this case, If Field A is between 1/1 and 12/31, make Field B white, else,
make Field B yellow?


Just select the option for the Between operator and enter
the dates in the other two boxes. Make sure you use the #
signs around the dates and include the year. E.g.
#1/1/2007#
 
Hi,

I saw another post which mentioned the EXPRESSION IS option. This is used
to refer to a control other that the one the CONDITIONAL FORMATTING is on.
This worked like a charm. Thanks for replying.
 
Back
Top