473,505 Members | 13,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change colors in datasheet subform dynamically

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
4 20750
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
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5344
by: ivan | last post by:
I have a form (CustomerImfo) that has a subform within it (order). Within that subform is another subform (OrderDetail). That subform (OrderDetail) is displayed in Datasheet view. When I am...
3
13383
by: A Clark | last post by:
I have a subform that displays a datasheet. There are a couple of different queries that can be displayed in the datasheet. The queries are available in a combo box on the main form. The problem...
1
2289
by: Richard Sherratt | last post by:
I added a new field to a table in the tables database. In the code database, I added a new column for the new field to a datasheet subform. I opened it in datasheet view and moved the column to the...
5
8608
by: kotowskil | last post by:
A report has a subform. The subform is set to datasheet view and its RecordSource is a select query that includes a memo field from the source table. The memo field's Can Grow property is Yes,...
7
6238
by: Ken Mylar | last post by:
First a quick background on the form: I have a form that is normally viewed in Single form mode. It has a subform on it that is in datasheet view. The main form is for work orders and the...
2
4241
by: ghat12 | last post by:
Hi, I am trying to print a subform containing approx 50 columns in datasheet view. The printout cannot fit more than 8-10 columns. Does anyone know of any way to print all columns; i don't care...
2
10125
by: ncsthbell | last post by:
I have a form with a subform and I am trying to change the size of a column on the subform. I am following the instructions in the access help 'Change the layout of a subform in Datasheet view" to...
4
6468
by: TD | last post by:
I am trying to change the forecolor of a field in a subform that is in datasheet view. I am using Access 2007. I have tried everything I can think of to do this but the text still appears in...
7
9277
AccessIdiot
by: AccessIdiot | last post by:
This is driving me nuts. I have an unbound textbox (txt_SumSize) in my subform that holds the total of a field (Debitage_Size_Quantity)seen in datasheet view (control source =Sum(). I have an...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.