Solved

How make copy on a textbox on a report red

Posted on 2011-03-23
5
236 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
[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
  • 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:Michael Fowler
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

632 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