Results 1 to 8 of 8
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    Change field background color based on query results


    ! would like to change the background color of a field that is the result of a Unique Values query. I am trying to get a list of invoices where all the line items are approved. I cant seem to get it to work the way I want because if even one invoice line item is approved it will show up as approved.

    Is there a way to change the background color of the invoice field to red if ANY of the Approved line items are = False

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You could check Conditional Formatting on a Form. This may help.

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Yes, thank you. I am aware of conditional formatting but I am not sure the formula to get it to work correctly. I have 20 lines associated with an invoice, IN1234, and each line has an approval checkbox. I want the box to show red if there are any checkboxes that have NOT been checked.

    So the query that produces the results on the continuous form is a DISTINCT query but I need to be able to check each line item that is tied to that Individual Invoice and I am not sure how to do that.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I would suggest looking at the InvoiceDetail.

    something along this line of thinking: Find those Invoices where the detail has an unchecked checkbox, then find all of the invoices that are not in the first list.

    Code:
    Select invoiceID from InvoiceDetail
    where InvoiceID NOT IN
    (Select invoiceID from InvoiceDetail
      where ApprovalCheckBox = False)

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Can use domain aggregate functions. Beware they can be slow.

    DCount("*", "tablename", "checkbox=False And Invoice='" & [Invoice] & "'")

    Can be in query or textbox or in Conditional Formatting expression. Then Conditional Formatting can set background color if the count is <> 0.
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Thanks Orange, I was able to use a query June 7 gave me to make only the invoices I want appear so I dont need to make the ones I dont want red anymore

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Actually, I just gave you a domain aggregate expression. The query suggested by orange might be more efficient as a form or report RecordSource, although I have known the NOT operator to have issues.
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    I was refer to the help you gave me in the thread https://www.accessforums.net/access/...ail-44767.html

    For those looking, I used the query from the thread above to only show invoices that were fully approved so I did not end up needing the conditional formatting to highlight an invoice that was not fully approved.

    Thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 06-01-2014, 12:05 PM
  2. Replies: 3
    Last Post: 01-01-2014, 11:21 PM
  3. Replies: 2
    Last Post: 08-14-2013, 04:29 PM
  4. Change field color based on result
    By dniezby in forum Programming
    Replies: 1
    Last Post: 05-01-2013, 09:43 PM
  5. Change Row Background Color Programmatically
    By sales@4bco.com in forum Programming
    Replies: 2
    Last Post: 10-25-2009, 11:17 AM

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