473,379 Members | 1,123 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 20725
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.