467,169 Members | 958 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,169 developers. It's quick & easy.

Conditional Formatting Colors and Code

In a Continuous form, I want to use Conditional Formatting to change
the background color of a date field based on a condition.

1-The color chart in the CF menu option offers limited colors. How can
I use the custom colors I need ???

2-Is Conditional Formatting available in code, so that I can use more
than 3-conditions and have more versatility than the Access2k CF menu
option offers ???

Thanks Greg

Mar 3 '07 #1
  • viewed: 13217
Share:
4 Replies
On 3 Mar 2007 13:59:40 -0800, "Ap******@gmail.com"
<Ap******@gmail.comwrote:

Re: 1: Too bad, so sad. But read Re: 2

Re: 2: Sure: you can create a single condition with "Expression Is",
and then as the expression you can specify your own function, which
would test all (more than 3) conditions you need. This must be a
public function in a standard module, returning a boolean.

AFAIK, there is no documented way to programmatically manipulate the
conditional formatting, but if you feel adventurous: open the object
browser (F2) right click Show hidden members then search for
"condi" (no, not Condi :-)) and you'll find interesting classes like
FormatCondition and FormatConditions to be explored.

-Tom.
>In a Continuous form, I want to use Conditional Formatting to change
the background color of a date field based on a condition.

1-The color chart in the CF menu option offers limited colors. How can
I use the custom colors I need ???

2-Is Conditional Formatting available in code, so that I can use more
than 3-conditions and have more versatility than the Access2k CF menu
option offers ???

Thanks Greg
Mar 3 '07 #2
Thankyou Tom

I experimented with the "Expression Is" option, and was able to
satisfy my condition issues.

However, I really need to be able to set the background color of a
field meeting the condition, to colors not showing on the grossly
limited color chart. There must be a way???

Thanks Greg

Mar 4 '07 #3
I believe I figured it out.

Me.txtMyTextBox.FormatConditions(0).BackColor = RGB(64, 128, 196)

I would use this expression in code in the LoadForm event to establish
my choice of color for the first Conditional Formatting result. And
follow this method for the others.

Greg

Mar 4 '07 #4
Ap******@gmail.com wrote:
>In a Continuous form, I want to use Conditional Formatting to change
the background color of a date field based on a condition.

1-The color chart in the CF menu option offers limited colors. How can
I use the custom colors I need ???

You can use colors other than what the palette offers by
using the FormatConditions "collection".

Private Sub Form_Open(Cancel As Integer)

Me.txtID.FormatConditions(0).BackColor = RGB(255,240,240)
Me.txtID.FormatConditions(1).BackColor = RGB(240,255,240)
Me.txtID.FormatConditions(2).BackColor = RGB(240,240,255)

End Sub

Regardless of what you do, a single control can only have
the default color plus three conditional colors. If you
need to go to extremes, you can play games by stacking text
boxes on top of each other and get another three colors for
each text box.

--
Marsh
Mar 4 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Alex | last post: by
2 posts views Thread by jeffgeorge | last post: by
reply views Thread by GGerard | last post: by
1 post views Thread by dddsssdddsss@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.