Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Change lable and text control based on value

Posted on 2011-10-13
3
Medium Priority
?
189 Views
Last Modified: 2012-05-12
I have a user request that if the due date is less than Today plus 7 days, they want the lable and text control to appear on the report as red.  I tried the below in the group format, but it turns all lables and due date text controls to red.  This is an Access 2003 report.
Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
'If Due date is with 7 or less days, make the box and data red

If Me.TaskDueDate <= (Date + 7) Then
     Me.lblTaskDueDate.BorderColor = RGB(239, 5, 29)
     Me.lblTaskDueDate.ForeColor = RGB(239, 5, 29)
     Me.lblTaskDueDate.FontBold = True
     
     Me.TaskDueDate.BorderColor = RGB(239, 5, 29)
     Me.TaskDueDate.ForeColor = RGB(239, 5, 29)
     Me.TaskDueDate.FontBold = True

End If


End Sub

Open in new window

0
Comment
Question by:ssmith94015
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36965433
Try using "Conditional Formatting" instead of code.

Right-click a text box, and select Conditional Formatting.

Then, select "Expression Is" for the formatting type.

In the textbox provided, place the following:
[TaskDueDate] <= Date() + 7

And select the color you want for the formatting
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36965447
Not sure if you can conditionally format a label.  If you cant, you can always use a borderless texbox instead of a label on your report and get the same effect.
0
 

Author Closing Comment

by:ssmith94015
ID: 36965457
Actually, I just asked that very question as I have two conditions that need to be met.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

564 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