Results 1 to 4 of 4
  1. #1
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23

    Multiple if statements on combobox background colors

    Hi folks! I have this silly thing i cant get to work.



    "I have this combobox with values stored in a table, for each record it represents the status of the order, and each value has a background color."

    This seems to work just fine with just 1 single IF statement...but when i add another, its just a white background (nothing happend)
    Can someone explain to me whats happening and how i can add multiple IF statements here?

    Private Sub Form_Current()
    DoCmd.ShowToolbar "Ribbon", acToolbarYes
    If orderstatuscombo.Value = "Order created" Then
    orderstatuscombo.BackColor = 3881966
    If orderstatuscombo.Value = "Pre-configuration" Then
    orderstatuscombo.BackColor = 1219071
    Else
    orderstatuscombo.BackColor = 16776960
    End If
    End Sub

    Also, what should this combobox do in the property sheet? What kind of event is it.

    Im so lost now with trying anything...please help!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Make the list box have 2 columns.
    1 w the value to pick
    1 hidden with the backcolors.
    when user picks the item, grab the back color. No IFs.

    Cbo.backcolor= cbo.colomn(1)

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    which of the backcolors listed is white?

    Also, confirm what type of form - single or continuous/multiple item? If the latter you need to use conditional formatting - your code will not work

  4. #4
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23
    Hi guys. Thanks for the help and swift reply

    I indeed came to the conclusion that conditional formatting works the best for me. It's just damn handy.

    For anyone wanting to know how i solved it;

    Go to design view of your form and right click the combobox.
    Select conditional formatting.
    Make a new rule
    Set the criteria however you want it to be
    Edit the color

    Set a new rule for each value in the combobox.
    (This is only handy if you have few to a little combo boxes, cause it gets tedious...)

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

Similar Threads

  1. Multiple iif Statements in 1 Exp
    By dmd in forum Queries
    Replies: 16
    Last Post: 12-01-2015, 08:15 AM
  2. Replies: 2
    Last Post: 09-04-2013, 12:11 PM
  3. Multiple iif statements
    By rlsublime in forum Queries
    Replies: 3
    Last Post: 04-25-2012, 10:33 AM
  4. Multiple SQL Statements
    By springboardjg in forum Queries
    Replies: 1
    Last Post: 04-18-2011, 10:32 AM
  5. Multiple IIF statements
    By KevinMCB in forum Queries
    Replies: 4
    Last Post: 12-03-2010, 01:35 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