473,789 Members | 2,530 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 20788
YOu can easily modify the FormatCondition s 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.goo gle.com...
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_Telemarket ing_Leads

Public Function SetEvenAlternat eFunction()
Dim objfrc As FormatCondition

'Form Name Textbox Control on Subform
Form_Telemarket ing_Leads.Phone .FormatConditio ns.Delete
Set objfrc = Form_Telemarket ing_Leads.Phone _
.FormatConditio ns.Add(acExpres sion, , _
("not isnull([Phone])"))
With Form_Telemarket ing_Leads.Phone .FormatConditio ns(0)
.BackColor = RGB(0, 255, 0)
.ForeColor = RGB(255, 0, 0)
End With

Form_Telemarket ing_Leads.Repai nt

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************ *************** *************@l invalid.com> wrote in message news:<Oq******* *************@u rsa-nb00s0.nbnet.nb .ca>...
YOu can easily modify the FormatCondition s 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.goo gle.com...
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 FormatCOndition s object from within a function
called by CF. THis means you are limited to a total of 3
colors(conditio ns).
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.goo gle.com...
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_Telemarket ing_Leads

Public Function SetEvenAlternat eFunction()
Dim objfrc As FormatCondition

'Form Name Textbox Control on Subform
Form_Telemarket ing_Leads.Phone .FormatConditio ns.Delete
Set objfrc = Form_Telemarket ing_Leads.Phone _
.FormatConditio ns.Add(acExpres sion, , _
("not isnull([Phone])"))
With Form_Telemarket ing_Leads.Phone .FormatConditio ns(0)
.BackColor = RGB(0, 255, 0)
.ForeColor = RGB(255, 0, 0)
End With

Form_Telemarket ing_Leads.Repai nt

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************ *************** *************@l invalid.com> wrote in
message news:<Oq******* *************@u rsa-nb00s0.nbnet.nb .ca>...
YOu can easily modify the FormatCondition s 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.goo gle.com...
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 FormatCOndition s object from within a function
called by CF. THis means you are limited to a total of 3
colors(conditio ns).
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
5361
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 entering customers and their respective orders, the first order entered is fine with the "tab" field orders correct. On the second and subsequent orders, when I go from the Order form to the subform "OrderDetail", the curser goes to the wrong field...
3
13425
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 I am having is that when I change the query all the column widths remain the same. This doesn't look very good. I can't figure out a way to set the column widths. I have tried.. Subform.controls(Name of Column).columnwidth = IntColumnWidth
1
2323
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 position I wanted it. No records are returned by the form's query (it has a "Where ID = -1" clause and the GoToRecord proc on the main form changes the subform's recordsource). When I opened the form and started adding data to the subform,...
5
8628
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, and the subform Detail section's Can Grow property is Yes. The report Detail section's Can Grow property is also Yes. When run, the select query's memo field has all the data. However, when I run the report, the subform does not show all the...
7
6262
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 subform is for parts used on the work order. On the main form I have a LaborTotal (from main form), PartsTotal (from subform) and TotalCost (which is Labor + Parts). All works fine as is. Now to the question: I have a button on my main form to browse...
2
4267
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 if the printout spans multiple pages. FYI, the records displayed in the sub-form are dynamically obtained based on some ad-hoc querying in the main form. Any report, etc. generated will have to have the same set of records.
2
10146
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 change the width but it is not working. The column source is a table and it appears that no matter how I size the column, it remains the size of the "name" of the column from the table. My subform has a FormHeader (with nothing defined for it) and...
4
6490
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 black. I need it to appear in red if the field has the word "YES" in it. Is there something in Access 2007 that keeps this from working?????
7
9310
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 unbound textbox on my form (txt_SizeTotal) that gets the value from the subform footer when the form loads: Private Sub Form_Load() Me.txt_SizeTotal = Me!sbfrm_DEBITAGE_Size.Form! End Sub
0
9506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10193
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6761
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.