Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How make copy on a textbox on a report red

Posted on 2011-03-23
5
Medium Priority
?
241 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

719 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