Solved

How make copy on a textbox on a report red

Posted on 2011-03-23
5
234 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

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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