Results 1 to 7 of 7
  1. #1
    donetteo is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    4

    Conditional formatting for various fields and contents

    Hi,

    I have a form with a PRIORITY field and also a TIME field.

    What I am trying to accomplish is;

    If PRIORITY=Critical and the time is greater than 1 hour - Display the time in RED.
    Also...
    If PRIORITY=High and the time is greater than 24 hours - Display the time in RED.

    I was able to get the first parameter to work. So the Criticals over an hour are displaying in red, but I cannot get both to work in the same report. Any assistance would be greatly appreciated.

    Thank you.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    try swapping them round - time is greater than 1 hour will include time is greater than 24 hours so the second one will never be met although the priority may make a difference.

    alternative, since the formatting is the same is to combine both expressions into one (with an OR between them)

  3. #3
    donetteo is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    4
    Thank you for the quick response.
    I tried what you said, but I must be confused or missing something. I still only get one scenario to change with the formatting. Please see below my formatting line. Any further guidance would be appreciated.

    Hour([Time])>4 And [Priority]="1 - CRITICAL" or Hour([Time])>24 And [Priority] ="2 - HIGH"

    Only the Critical formatting is working correctly.
    Thanks.

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    one problem is you are using Time as a field name which is a reserved word, even with square brackets it can result in unexpected results so recommend to change it to something else. You also need to use brackets around the two statements so Access can evaluate properly (a bit like maths functions). Finally and the main reason it isn't working is the Hour function will only return an hour in the day - i.e. 0 to 23. See this link
    https://support.office.com/en-us/art...a-98df6955778f

    I don't know how you are getting your Time value, but look at using the datediff function instead.

  5. #5
    donetteo is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    4
    OK. I'm not using Time as a field name, I just renamed it in this communication to make clear what I am trying to accomplish.

    I am using the datediff function in the query that I used for the report, then I in the report I use =[Minutes]\60 & Format([Minutes] Mod 60,"\:00") to format the time the way I want it.

    This is the actual conditional formatting (Hour([Text20])>4 And [Rank]="1 - CRITICAL") Or (Hour([Text20])>24 And [Rank]="2 - HIGH").
    I included the brackets as suggested and the formatting still is not working correctly. Maybe this can't be done?

    Any further guidance would be appreciated.
    Thanks.

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    As previously explained, Hour returns a value between 0 and 23 so this

    Hour([Text20])>24

    will never be true

  7. #7
    donetteo is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    4
    I got it to work using separate conditional formatting statements and using the Day parameter for the Text20 values greater or equal to 24.
    Thanks.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-12-2015, 10:46 AM
  2. Conditional Formatting or VBA for Report Fields
    By GoldenOrb in forum Reports
    Replies: 3
    Last Post: 10-24-2013, 03:35 PM
  3. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  4. Replies: 5
    Last Post: 03-14-2013, 01:52 PM
  5. Replies: 6
    Last Post: 09-27-2012, 08:27 AM

Tags for this Thread

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