ttist25
asked on
Change Back Color of Rectangle in Query
Hello,
I have a microsoft access 2007 database with a report fed by a query. I'm using iif statements to get values from the record and display text in text fields.
I would like to also use iif statements to change the Back Color of a rectangle on my report based on the value of a field.
Here's an example of what I'm doing to display text:
iif(myTable.MyField_Descri ption = "Value1",
"Text for value1.",
"Text for everything else.")
AS myTextBox,
That will display the appropriate text in myTextBox.
I would like to use the same thing to change the back color of a rectangle but I'm not sure of the syntax. It would be something like this:
iif(myTable.MyField_Descri ption = "Value1",
my.Rectangle.BackColor="#0 00000",
my.Rectangle.BackColor="#F FFFFF")
AS myRectangle,
FYI - if you haven't figured it out by now, I need to point out that I'm a serious noob with this stuff.
TIA!
I have a microsoft access 2007 database with a report fed by a query. I'm using iif statements to get values from the record and display text in text fields.
I would like to also use iif statements to change the Back Color of a rectangle on my report based on the value of a field.
Here's an example of what I'm doing to display text:
iif(myTable.MyField_Descri
"Text for value1.",
"Text for everything else.")
AS myTextBox,
That will display the appropriate text in myTextBox.
I would like to use the same thing to change the back color of a rectangle but I'm not sure of the syntax. It would be something like this:
iif(myTable.MyField_Descri
my.Rectangle.BackColor="#0
my.Rectangle.BackColor="#F
AS myRectangle,
FYI - if you haven't figured it out by now, I need to point out that I'm a serious noob with this stuff.
TIA!
Have you tried using conditional formatting? Don't think that will actually work for a "rectangle", but you could create a textbox for the [MyField_Description] on the report, then use conditional formatting to test if the fieldvalue = "Value1" and if so use a conditional format.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok - that gives me good ideas on the syntax of changing the color but, is it possible to do this inside my query without creating a sub?
"is it possible to do this inside my query without creating a sub? "
A query is like a table that displays data. I can't see a way to use a table to change bacground color without using an action statement.
The sub is there in the report, you only add the action statement to set the color on condition.
A query is like a table that displays data. I can't see a way to use a table to change bacground color without using an action statement.
The sub is there in the report, you only add the action statement to set the color on condition.
ASKER
Definitely not the most graceful solution I'm sure but, here's what I ended up doing:
Works great! Thanks for the help.
I replaced the rectangle with a text box of the same size and shape
I used my iif statement as described above and set the text to either "On" or "Off"
Then I used the Conditional formatting toolbar thing to set the background fill and foreground font accordingly (either both gray or both white)
Works great! Thanks for the help.
Glad I could help.