?
Solved

Access 2010 - Conditional formatting on a Label

Posted on 2010-11-15
5
Medium Priority
?
1,129 Views
Last Modified: 2012-06-22
Hi,
On an Access 2010 report, I'm trying to change the behavior of a label (not a text box) to where if data is = 0 in another text box field, then the label changes color.
I'm fairly new to Access 2010 so your help is appreciated in advance.
thank you,
bcarmi
0
Comment
Question by:bcarmi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 34139607
The easiest way to do this would be ... to use a Text box to emulate the Label, then use Conditional Formatting in the text box to change the color ... based on the condition in the other text box.

mx
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 34139683
Where is this label (header, detail, footer)?

I don't know about 2010, but 2007 has a Format event associates with each of the above, and I'm sure this functionality is still there with 2010.  Use that event to change the backcolor of the label.

Private sub Detail_Format

    if [somefield] = "abc" Then
        me.YourLabelName.Backcolor = rgb(255, 0, 0)
   elseif [somefield] = "def" then
        me.YourLabelName.Backcolor = rgb(0, 255, 0)
   elseif [somefield] = "ghi" then
        me.YourLabelName.Backcolor = rgb(0, 0, 255)
   elseif [somefield] = "jkl" then
        me.YourLabelName.Backcolor = rgb(255, 255, 0)
   else
        me.YourLabelName.Backcolor = rgb(255, 0, 255)
   end if
End Sub

You could also use the Switch function, or possibly the Choose function (if the values of the field you want to test are continuous).

     

0
 

Author Comment

by:bcarmi
ID: 34139942
Hi,
Thank you for the swift reply.

fyed: The label is in the detail, but which event loads the page? I see "On click, format, dbl click, mouse down, mouse up, mouse move, paint, print, and retreat."

DatabaseMX: How do I go about emulating a Label with a text box? When I create textbox and put in an a value X, i get X is not a vaild field name or expression.

Thank you,
bcarmi
0
 
LVL 75
ID: 34139978
"When I create textbox and put in an a value X, i get X is not a vaild field name or expression."

In the text box Control Source, you need an expression"

="MyLabelCaption"

include the equals sign ... an surround the text with double quotes.

mx
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 34140258
If you want to use the Format event, click on the "Detail" bar that divides the header from the detail section.  Then view the Events tab on the Properties dialog and find the Format event.

Select [Event Procedure] from the dropdown on that line, then click the "..." to the right of that to view the VBA procedure.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question