By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,579 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

change colors in datasheet subform dynamically

P: n/a
TIA! I would like to know if there is a way to dynamically change the
colors of Subform items? I have already set in place Conditional
Formatting so each row has an alernating color scheme, but what I am
looking for is a way <behind a button click event> to dynamically
change the Subform's color scheme so the listing can have color
choices. Is this even possible?

Thanks again to anyone who may be able to help
Wes
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
YOu can easily modify the FormatConditions object at runtime and change
any of the exposed color props. For sample code see:
http://www.lebans.com/conditionalformatting.htm

I would suggest that you simply pop up the standard Windows Color Dialog
from the Click event of the relevant CommandBUtton control(s) on your
Form. FOr sample code see:
http://www.lebans.com/fontcolordialog.htm
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"codemonkey" <we************@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
TIA! I would like to know if there is a way to dynamically change the
colors of Subform items? I have already set in place Conditional
Formatting so each row has an alernating color scheme, but what I am
looking for is a way <behind a button click event> to dynamically
change the Subform's color scheme so the listing can have color
choices. Is this even possible?

Thanks again to anyone who may be able to help
Wes


Nov 12 '05 #2

P: n/a
Thanks Stephen for the advice!

Currently I am receiving the error: Can't modify the control's
Conditional Formats right now.

What I have done is under the Expression Is property for each
Conditional Formatting row (alternating rows) is set them to call a
function in which I was attempting to dynamically set the color inside
the function each row calls. The code is as follows: (located in a
module)

*Note: Phone is one textbox on a subform located on
Form_Telemarketing_Leads

Public Function SetEvenAlternateFunction()
Dim objfrc As FormatCondition

'Form Name Textbox Control on Subform
Form_Telemarketing_Leads.Phone.FormatConditions.De lete
Set objfrc = Form_Telemarketing_Leads.Phone _
.FormatConditions.Add(acExpression, , _
("not isnull([Phone])"))
With Form_Telemarketing_Leads.Phone.FormatConditions(0)
.BackColor = RGB(0, 255, 0)
.ForeColor = RGB(255, 0, 0)
End With

Form_Telemarketing_Leads.Repaint

Set objfrc = Nothing
End Function

Is it possible to dynamically set the row's color this way? I am
slightly confused when the color could be changed (in what Event this
could be performed) so I created a Function for Even and Odd rows. I
want to ultimately have the ability to change the color scheme for
even/odd rows by pressing a button in which contains other
predetermined color choices for the Subform.

If you could offer anymore advice it would be GREATLY appreciated!!

Thanks!
Wes
"Stephen Lebans" <Fo****************************************@linval id.com> wrote in message news:<Oq********************@ursa-nb00s0.nbnet.nb.ca>...
YOu can easily modify the FormatConditions object at runtime and change
any of the exposed color props. For sample code see:
http://www.lebans.com/conditionalformatting.htm

I would suggest that you simply pop up the standard Windows Color Dialog
from the Click event of the relevant CommandBUtton control(s) on your
Form. FOr sample code see:
http://www.lebans.com/fontcolordialog.htm
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"codemonkey" <we************@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
TIA! I would like to know if there is a way to dynamically change the
colors of Subform items? I have already set in place Conditional
Formatting so each row has an alernating color scheme, but what I am
looking for is a way <behind a button click event> to dynamically
change the Subform's color scheme so the listing can have color
choices. Is this even possible?

Thanks again to anyone who may be able to help
Wes

Nov 12 '05 #3

P: n/a
You cannot modify the FormatCOnditions object from within a function
called by CF. THis means you are limited to a total of 3
colors(conditions).
I thought what you wanted to do was simply allow the user to select what
these 3 colors should be. Am I mistaken?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"codemonkey" <we************@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
Thanks Stephen for the advice!

Currently I am receiving the error: Can't modify the control's
Conditional Formats right now.

What I have done is under the Expression Is property for each
Conditional Formatting row (alternating rows) is set them to call a
function in which I was attempting to dynamically set the color inside
the function each row calls. The code is as follows: (located in a
module)

*Note: Phone is one textbox on a subform located on
Form_Telemarketing_Leads

Public Function SetEvenAlternateFunction()
Dim objfrc As FormatCondition

'Form Name Textbox Control on Subform
Form_Telemarketing_Leads.Phone.FormatConditions.De lete
Set objfrc = Form_Telemarketing_Leads.Phone _
.FormatConditions.Add(acExpression, , _
("not isnull([Phone])"))
With Form_Telemarketing_Leads.Phone.FormatConditions(0)
.BackColor = RGB(0, 255, 0)
.ForeColor = RGB(255, 0, 0)
End With

Form_Telemarketing_Leads.Repaint

Set objfrc = Nothing
End Function

Is it possible to dynamically set the row's color this way? I am
slightly confused when the color could be changed (in what Event this
could be performed) so I created a Function for Even and Odd rows. I
want to ultimately have the ability to change the color scheme for
even/odd rows by pressing a button in which contains other
predetermined color choices for the Subform.

If you could offer anymore advice it would be GREATLY appreciated!!

Thanks!
Wes
"Stephen Lebans"

<Fo****************************************@linval id.com> wrote in
message news:<Oq********************@ursa-nb00s0.nbnet.nb.ca>...
YOu can easily modify the FormatConditions object at runtime and change any of the exposed color props. For sample code see:
http://www.lebans.com/conditionalformatting.htm

I would suggest that you simply pop up the standard Windows Color Dialog from the Click event of the relevant CommandBUtton control(s) on your Form. FOr sample code see:
http://www.lebans.com/fontcolordialog.htm
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"codemonkey" <we************@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
TIA! I would like to know if there is a way to dynamically change the colors of Subform items? I have already set in place Conditional
Formatting so each row has an alernating color scheme, but what I am looking for is a way <behind a button click event> to dynamically
change the Subform's color scheme so the listing can have color
choices. Is this even possible?

Thanks again to anyone who may be able to help
Wes


Nov 12 '05 #4

P: n/a

Thanks for the reply Stephen. I appreciate your patience!

What I was trying to do initially was have a button (that when clicked)
would cycle through multiple preset forecolor and backcolor settings -
in turn changing the alternating rows of the Subform with a new color
scheme (one click at a time until the user found one color scheme he
liked).

I have seen this done in the link below (looking at Colorcon.zip) and I
understand the principle idea of having a long textbox in the
background.
http://www.mvps.org/access/forms/frm0024.htm

It's very complex and I thought there must be an easier way to
accomplish this without all the links to the long textbox, table fields
etc...

Maybe I am trying to do the impossible here but I was trying to use the
fAlternateRowA Function to get the Even/Odd row count and simply change
the alternating row color.

Explanation:
I thought by setting the Conditional Formatting object (Forecolor and
Backcolor properties programatically) either with a function linked in
the Condition1 'Expression Is' on the CF side would work.
OR
By removing the CF conditions altogether thus causing the Subform rows
to have no color at all when the Subform initially loads AND placing all
the color changing code behind a button click would be easy but I have
found it is quite hard to do.
Behind the button click I am having trouble getting Even/Odd row numbers
for starters so I found myself stuck because I can only get the Even/Odd
row values by placing the fAlternateRowA calls in the CF Conditions
Side.

Maybe I'll take a look at the Colorcon.zip example again and see if I
can find an easier way to do what they did. It's quite crafty.

Anyone who may have tinkered with that example is welcomed here! =]

TIA!!
Wes

Previous Message:
From: Stephen Lebans
Date Posted: 11/17/2003 5:33:00 PM

You cannot modify the FormatCOnditions object from within a function
called by CF. THis means you are limited to a total of 3
colors(conditions).
I thought what you wanted to do was simply allow the user to select what
these 3 colors should be. Am I mistaken?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.