Solved

How make copy on a textbox on a report red

Posted on 2011-03-23
5
231 Views
Last Modified: 2012-06-27
I am trying to make the value in a date textbox turn red if certain criteria exists.  Here is my code but it is not turning red.  I have this in the onformet event of the detail section of the report.

    If Me.txtFinApprovalDueDate < Now() And Me.txtFinApprovalRecdDate = "" Then
        Me.txtFinApprovalDueDate.ForeColor = vbRed
    End If

What is wrong with this?
0
Comment
Question by:SteveL13
  • 3
5 Comments
 
LVL 4

Expert Comment

by:MaximumIQ
ID: 35202435
I'm not sure what the date format is in your box but "Now" returns full date and time, if that's a different format than your box, Excel might be having a hard time calculating it. You should try the "DateDiff" function, which should account for different date/time formats or try setting the format of your "Now"

Datediff("d",<Date1>, <Date2>)
0
 
LVL 23

Expert Comment

by:Michael74
ID: 35202446
I don't believe that the if statement can ever be true as it states that the date being tested must be less than now AND empty. Try changing this to

If Me.txtFinApprovalDueDate < Now() Or Me.txtFinApprovalRecdDate = "" Then

Michael
0
 
LVL 4

Accepted Solution

by:
MaximumIQ earned 500 total points
ID: 35202557
They're two different boxes Michael74. one is Approval Due and the other is Approval Received. So it sounds like he wants it to go red, if it's past the due date and it has no value in the approval received box.

By the way I just thought about it, and DateDiff won't work for you because lets say you tell it if the datediff is 0 then blah blah, that will only work if the date of the box and today's date are the same but not if it's newer or older.

Try the code below. I tested it and it works
 
If DateValue(Me.txtFinApprovalDueDate.Text) < DateValue(Now) Then
        Me.txtFinApprovalDueDate.ForeColor = vbBlack
    End If

Open in new window

0
 
LVL 4

Expert Comment

by:MaximumIQ
ID: 35202578
This applies to Excel and should stay in the Excel Zone
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35202616
SteveL13, you might like to ask CS to add a zone to this question.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now