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 18134
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: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |