Results 1 to 6 of 6
  1. #1
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55

    Conditional Formatting - Comparing a Percent Field to a Text Field


    I'm having issues with conditional formatting not displaying correctly when comparing a Textbox field formatted as a percent to a textbox field (titled Target) with no format set but containing a percentage, e.g. 83%.

    The Target field can contain either a number, a percentage, or text (yes or no). I have successfully set up conditional formatting to compare a textbox containing a number with a general format to the Target field with the help of the Val() function and I have successfully set-up comparing a combo box containing either a Yes or No to the Target field as well.

    I set-up the first condition for the Percent field's expression as [Percent]<Val([Target]) to display in a red font, however, all of the fields are displaying in red even if the percent value is greater than the target. Any guidance as to what I'm doing wrong will be greatly appreciated. Thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Cannot replicate issue. If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    Example database attached. The Comparison 2 fields are not working correctly. Thanks.

    Margaret
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The real value in PercentCalc calculated field is like 0.666666666666667. This is why the conditional format does not work as you want. This is why I never apply formats or lookups in tables. I want to see the real value.

    Try:

    Int([PercentCalc]*100)<Val([Target])

    or if you want rounding

    CInt([PercentCalc]*100)<Val([Target])
    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.

  5. #5
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    Thanks June7. Worked perfectly. I have removed the formatting in the table and understand your point. Conditional formatting is somewhat glitchy in general. While it does work in the form, it first shows black before applying the correct colors. Anyway to correct that?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Not that I know of.
    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. Replies: 3
    Last Post: 04-18-2017, 07:45 AM
  2. Replies: 1
    Last Post: 01-05-2017, 05:14 PM
  3. Replies: 7
    Last Post: 03-03-2014, 01:36 PM
  4. Replies: 1
    Last Post: 04-26-2012, 08:31 PM
  5. Replies: 5
    Last Post: 03-14-2012, 08:32 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