Results 1 to 15 of 15
  1. #1
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21

    Conditional Formatting w Multiple Conditions

    Good afternoon,

    I have a continous subform on a form where I need to use conditional formatting to change the colors of a combo box based on the value selected. The data type of the values are all short text.

    Combo box drop down is [Item_ID] selections I want to affect are SWA, BH, FREIGHT (and a few others but you get the idea)



    I know how to use conditional formatting a little bit. But I want to know if any of these codes will work, or how if I need to make individual rules for all of the selections I want to be affected.

    These were my ideas, but I am not sure if the OR, or a , is how I should separate the values if either of these is right at all.

    Expression is [Item_ID] = "SWA" OR "BH" OR "FREIGHT"

    Expression is [Item_ID] = "SWA" , "BH" , "FREIGHT"


    I am unable to make edits to the system at this time or I would just use trial and error.

    Any advice is appreciated.

    Thank you!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Item_ID is a text field set as primary key and you save descriptive text values?

    Expression is [Item_ID] = "SWA" OR [Item_ID] = "BH" OR [Item_ID] = "FREIGHT"

    or

    Expression is [Item_ID] IN ("SWA", "BH", "FREIGHT")
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Neither of those is right. You could try

    Expression is eval([Item_ID] & “ in ( ‘SWA’, ‘BH’ , ‘FREIGHT’)”)

    note I am on my phone so the quotes will need correcting

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Both of my suggestions worked. Why would Eval() be needed?
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    In vba you cannot use ‘in’ unless you enclose it in eval. Was on my phone and couldn’t remember if a conditional format expression was in vba or sql

  6. #6
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Sorry, totally forgot to mention I am using the conditional formatting from the ribbon in design view.

    the name Item_ID is not the primary key, just the name of the field. Probably should have named it something else.

    so the format

    Expression is [Item_ID] = "SWA" OR [Item_ID] = "BH" OR [Item_ID] = "FREIGHT"

    or

    Expression is [Item_ID] IN ("SWA", "BH", "FREIGHT")


    should work in the conditional formatting ribbon?

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Why ask? Try it then report back what works and what doesn’t

    edit @june, just realised you may be thinking I was commenting on your post - I was actually commenting on the original post

  8. #8
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    @CJ_London

    Lol yes I know that would be the logical way to go about it.. however I went down a rabbit hole trying multiple ways to get it to work and didn't want to waste anymore time if I was totally off base or if it had to be done in another view than design. So many times I think I am on the right path and end up going down it way too far only to realize my mistake. Lol.. guess it is probably a good learning experience.

    I am also not able to make edits at the moment. But once I am able to go in and make some changes I will test and repot back!

    Thank you all for your help!

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    why can't you make edits at the moment? - sounds like your setup is wrong....

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Well, there is no place else to create Conditional Formatting rules except with VBA.

    CJ, I figured you were addressing the original post but my reply was still pertinent. I tested expressions before posting suggestion. IN() worked for me without Eval().
    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.

  11. #11
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Too many other users were in the system using the form to edit it at the time.

    None of these suggestions seem to be working. I will keep trying different variations.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by HK123 View Post
    Too many other users were in the system using the form to edit it at the time.

    None of these suggestions seem to be working. I will keep trying different variations.
    You should NOT even be even tryong to attempt to modify a production system.
    You do it and test it on your development system. And when thoroughly tested and working.
    , does it become the production system.
    ,
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What does "None of these suggestions seem to be working." mean - what happens?

    What other variations could you try? I tested my suggestions and they worked.
    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.

  14. #14
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Yikes, I did not know you could not make edits to an active system. I just thought nobody could be using it at the time it was being worked on. Now that I know I will only make edits on copies to ensure everything is working beforehand.

    That being said I am not going to continue trying to change the format at this time.

    Thank you all for your help.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Well, can make edits to active system if you want but probably shouldn't and depends which file you meant. A multi-user database should be split and each user runs their own copy of frontend. Make edits to a master frontend anytime then publish it so users can replace their local copy. If you need to make edits to backend then yes, definitely wait until no one is using. Make sure to backup first.
    Last edited by June7; 04-01-2024 at 02:12 PM.
    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 If with two conditions and Dlookup
    By charly.csh in forum Access
    Replies: 7
    Last Post: 05-02-2020, 10:24 PM
  2. Replies: 7
    Last Post: 05-02-2020, 09:29 AM
  3. Replies: 1
    Last Post: 04-30-2014, 05:26 PM
  4. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  5. Conditional Formatting with more than 3 conditions
    By cactuspete13 in forum Programming
    Replies: 3
    Last Post: 12-10-2012, 01:03 PM

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