Results 1 to 13 of 13
  1. #1
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6

    Conditional Formatting on Dates

    I am trying to apply conditional formatting to a field on a report that is a date from the underlying table (field name [maturity date3]). I want to highlight the field green if [maturity date3] is within 30 days from a specified date, red if it is within 60 days and yellow if it is within 90 days. (i.e., I want to tell the computer to compare the date in [maturity date3] to "10/1/2011" and highlight the field green if [maturity date3] is between 10/1/11-10/31/11, red if [maturity date3] is between 11/1/11-11/30/11, and yellow if [maturity date3] is between 12/1/11-12/31/11.



    How do I enter this information in the Rule window for Conditional Formatting? I have tried various expressions with no result and I am really getting frustrated. Further complicating this may be the fact that [maturity date3] may be left blank as well.

    I'd appreciate any help that can be offered!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    That is simply:
    Field Value is between #10/1/2011# and #10/31/2011#
    and same for the other date ranges. But this is hard coding a date range. You would have to modify the conditions each month.

    Maybe what you really want to know is the status of MaturityDate in relation to the current date? Is it past due, due in 30 days, 60 days, 90 days? That would be:
    Field Value Is less than Date()
    Field Value Is between Date() and Date() + 30
    Field Value Is between Date() and Date() + 60
    Field Value Is between Date() and Date() + 90
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by jpicard View Post
    I am trying to apply conditional formatting to a field on a report that is a date from the underlying table (field name [maturity date3]). I want to highlight the field green if [maturity date3] is within 30 days from a specified date, red if it is within 60 days and yellow if it is within 90 days. (i.e., I want to tell the computer to compare the date in [maturity date3] to "10/1/2011" and highlight the field green if [maturity date3] is between 10/1/11-10/31/11, red if [maturity date3] is between 11/1/11-11/30/11, and yellow if [maturity date3] is between 12/1/11-12/31/11.

    How do I enter this information in the Rule window for Conditional Formatting? I have tried various expressions with no result and I am really getting frustrated. Further complicating this may be the fact that [maturity date3] may be left blank as well.

    I'd appreciate any help that can be offered!
    You can also use this:

    DateDiff("d",[maturity date3],Date())<30

  4. #4
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6
    I tried Field Value is Between #10/1/2011# and #10/31/2011#, but it didn't work.

    I then tried the other suggestions, but nothing seems to be working. What am I doing wrong?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Don't know, works for me. Do you want to provide the project for analysis? Copy, remove confidential data, run Compact & Repair, zip if still large, attach to post. Attachment manager is below the Advanced post editor.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6
    OK, I found my problem...apparently, the shape fill was formatted to transparent instead of automatic, which was over-riding the conditional formatting application of colors!

    Now, another question - how do I tell it to use a specific date instead of just today's date?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    By hard code as demonstrated or reference to another field in the RecordSource. What determines the date to be used as criteria?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6
    If I run this report on 11/20/11, I want it to use 30, 60 & 90 days from 11/1/2011

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Okay.
    Field Value Is Between CDate(Month(Date()) & "/1/" & Year(Date())) and CDate(Month(Date()) & "/1/" & Year(Date()))+30

    Or
    Field Value is between DateSerial(Year(Date()),Month(Date()),1) and DateSerial(Year(Date()),Month(Date()),1)+30
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6
    That is extremely helpful. If I could ask for one last variation - how do I tell it a specific date to use? I imagine it is some variation on a parameter query, but I can't figure out how to set it up.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The conditional rule would have to refer to field in the RecordSource that would provide the criteria value. Again, what criteria would determine the date value? Perhaps a value input on a form or by parameter input prompt in query could become the criteria value. Construct a field in query with expression. The same value will be available to every record in the query.

    DateCriteria: [Forms]![formname]!controlname
    or
    DateCriteria: [enter date]

    Now refer to that constructed field in place of the Date() reference

    I don't use parameter input prompts because can't control validation. I would use a form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    jpicard is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    6
    Thank you so much for all your help (and patience) today June7! You have been a huge help to me.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Just finished testing. Had better luck with the Expression Is option.

    [maturity date3] Between DateSerial(Year([DateCriteria]),Month([DateCriteria]),1) And DateSerial(Year([DateCriteria]),Month([DateCriteria]),1)+30
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formatting
    By mm07nkb in forum Forms
    Replies: 1
    Last Post: 09-02-2011, 09:58 AM
  2. Using Conditional Formatting & Dates
    By djclntn in forum Forms
    Replies: 14
    Last Post: 04-12-2011, 07:04 PM
  3. Conditional Formatting
    By Desstro in forum Programming
    Replies: 3
    Last Post: 12-01-2010, 09:52 PM
  4. Conditional Formatting
    By cevatyildiz in forum Forms
    Replies: 8
    Last Post: 04-30-2010, 12:01 PM
  5. Conditional formatting
    By ylivne in forum Reports
    Replies: 1
    Last Post: 07-12-2009, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums