I know this one is kind of odd. But I was wondering if it were possible to apply some kind of conditional formatting where the background color of the form changes from one record to the next. Something like odd numbers could be the standard grey and even numbers could be pink or something like that.
Is this even possible?
thanks!
14 18189
I know this one is kind of odd. But I was wondering if it were possible to apply some kind of conditional formatting where the background color of the form changes from one record to the next. Something like odd numbers could be the standard grey and even numbers could be pink or something like that.
Is this even possible?
thanks!
conditional formatting will only work on active controls that contain values like textboxes. If the form is not continuous you could code something into the on current even of the form but in a continuous form it would change all the background colours each time.
Mary
As Mary says, use the form_current
Form doesnt have a background colour though, one I think u cant set anyway, though I could be wrong :)
U could set the backcolor for Detail
eg -
private sub Form_Current()
-
if me.somefield and 1 = 1 then
-
detail.backcolor = vbred 'odd
-
else
-
detail.backcolor = 16777215 'even
-
end if
-
end sub
-
But the colour u pick, u need to ensure form is still readable
u may find labels have different backgrounds as well, so it could be a case of going thru all controls that need colouring
As Mary says, use the form_current
Form doesnt have a background colour though, one I think u cant set anyway, though I could be wrong :)
U could set the backcolor for Detail
eg -
private sub Form_Current()
-
if me.somefield and 1 = 1 then
-
detail.backcolor = vbred 'odd
-
else
-
detail.backcolor = 16777215 'even
-
end if
-
end sub
-
But the colour u pick, u need to ensure form is still readable
u may find labels have different backgrounds as well, so it could be a case of going thru all controls that need colouring
Hey could you explain that code for me a bit? I'm not sure what is meant by me.somefield - is this any textfield control on the form? And what is 1=1? What does that mean to Access?
thanks!
ok, code was an example, based on your example of odd numbers
this is an example based on a value in your form
me.somefield refers to a control on your form
detail is the part of the form where all your controls exist
anding a numerical value with 1 is a way to check if its odd number or not -
private sub Form_Current()
-
-
'check if field on form called somefield is odd
-
if me.somefield and 1 = 1 then
-
detail.backcolor = vbred 'odd
-
else
-
detail.backcolor = 16777215 'even
-
end if
-
end sub
-
thanks, that's what I figured but I wanted to check if the 1=1 part referred to the value of somefield or if it was totally unrelated.
Sorry! I meant to get back to you when I had a chance to check it out. Does it matter that I want to do this in a form and not in a report?
I'll look into it now.
Sorry! I meant to get back to you when I had a chance to check it out. Does it matter that I want to do this in a form and not in a report?
I'll look into it now.
Oh, a form? Totally missed that.
Hmm.. maybe, you might have to use a different event though.
Yes I tried adapting it but I can't figure out how to make it work. :)
I tried just copying and pasting the code in, then calling it from the form_current event, but it wants parameters and I have no idea what parameters to give it! -
Private shadeNextRow As Boolean
-
Const shadedColor = 12632256
-
' Const shadedColor = 15726583 ' alternative shade colors
-
' Const shadedColor = 14078404
-
' Const shadedColor = 13356495
-
' Const shadedColor = 14281974
-
Const normalColor = 16777215
-
- Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
-
-
On Error GoTo Detail_Format_Error
-
-
' Choose a color based on the shadeNextRow value
-
If shadeNextRow = True Then
-
Me.Section(acDetail).BackColor = shadedColor
-
Else
-
Me.Section(acDetail).BackColor = normalColor
-
End If
-
-
' Switch the color for the next row
-
shadeNextRow = Not shadeNextRow
-
-
Detail_Format_Exit:
-
Exit Sub
-
-
Detail_Format_Error:
-
MsgBox "Error " & Err.Number & ": " & Err.Description
-
Resume Detail_Format_Exit
-
End Sub
-
-
Private Sub Form_Current()
-
Call Detail_Format
-
End Sub
I know this one is kind of odd. But I was wondering if it were possible to apply some kind of conditional formatting where the background color of the form changes from one record to the next. Something like odd numbers could be the standard grey and even numbers could be pink or something like that.
Is this even possible?
thanks!
You could use the 'Read Only' property of a Form in its Current() Event: - Private Sub Form_Current()
-
If Me.CurrentRecord Mod 2 = 0 Then 'Even Record
-
Me.Section(acDetail).BackColor = QBColor(13)
-
Else
-
Me.Section(acDetail).BackColor = QBColor(12)
-
End If
-
End Sub
Brilliant! That works great! Except the colors are a bit, um, extreme. I know custom colors are not easy in Access but is there a way to get away from the standard color choices?
And could you explain how the "read only" part comes in? I understand the code but am not sure what you meant by "read only".
Thanks so much! :)
melissa
Brilliant! That works great! Except the colors are a bit, um, extreme. I know custom colors are not easy in Access but is there a way to get away from the standard color choices?
And could you explain how the "read only" part comes in? I understand the code but am not sure what you meant by "read only".
Thanks so much! :)
melissa
I apologize for the confusing information:- CurrentRecord is a 'Read Only' property of a Form, meaning that it can only be read and not written to.
- The Color choices were of course ugly, but they were for demonstration purposes only.
- You can have your choice of literally 16,000,00 different colors via the RGB(red, green, blue) Function as indicated below.
- Me.Section(acDetail).BackColor = RGB(100, 213, 4)
-
Me.Section(acDetail).BackColor = RGB(1 - 255, 1 - 255, 1 - 255)
Place this code in the DblClick() Event of a Form's Detail Section for a simple demo: - Private Sub Detail_DblClick(Cancel As Integer)
-
Randomize
-
Me.Section(acDetail).BackColor = RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
-
End Sub
Very cool. I knew there must be a way to specify RGB rather than the number off the color palette. Thank you so much!!
:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gary |
last post by:
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the...
|
by: John Baker |
last post by:
Hi:
I imagine there are hundreds of responses to this question, but i cant find any on the
site using a search.
How do you change the background color of buttons? I know there must be an easy...
|
by: Georges Heinesch |
last post by:
Hi.
I have a form defined as datasheet view. Can I change the background
color of the individual fields (colums) separately (or all together)?
If yes, how?
TIA
--
|
by: DavidB |
last post by:
Greetings
I don't know if this is possible, but this group should be able to tell me.
I have a webpage with a changing message board (I understand the problems
with having changing text, but...
|
by: ngpost1 |
last post by:
I have a Crystal Reports.Net report being generated from my C#
application. I would like to change the background color of the
details section (not the text mind you) of the report on certain...
|
by: spit0033 |
last post by:
I have created a vertical menu with a white background, once a link is clicked i want that menu item's background color to change. Then once another menu item is clicked the first menu items...
|
by: bucchi |
last post by:
Hi,
I have an input field and I have to change the background color when the contents change.
The contents are changed by a pop-up. On submit of the pop-up the contents change.How can I...
|
by: Ulf Malmros |
last post by:
I want to change background color in a control in a form grid depending on the value in another control in the same grid. Can anyone giv me a hint about how to do this?
Please!
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |