Results 1 to 6 of 6
  1. #1
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283

    Color ComboBox values


    Hi gurus,

    I have a combobox with 4 values in it on a datasheet form. Is there a way to have each value appear in a different color within the drop down and therefore displayed in the form once selected?

    Thanks

  2. #2
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    this is what I have been trying so far but I get a user defined type not defined error. I have this on the on current event of the form

    Code:
    Option Compare Database
    
    Private Sub Form_Current()
        Dim dispo As Text, lngBlue As Long
        Dim lngRed As Long, lngYellow As Long, lngGreen As Long
        If Not IsNull(Me!Combo84.Value) Then
            dispo = Me!Combo84.Value
        Else
            Exit Sub
        End If
        lngRed = RGB(255, 0, 0)
        lngBlue = RGB(0, 64, 255)
        lngYellow = RGB(255, 255, 0)
        lngGreen = RGB(0, 178, 0)
        If dispo = "Proposal Sent" Then
            Me!Combo84.BackColor = lngRed
    ElseIf dispo = "Trade-In/Replaced" Then
            Me!Combo84.BackColor = lngBlue
    ElseIf dispo = "Kept/Renewed" Then
            Me!Combo84.BackColor = lngYellow
        Else
           Me!Combo84.BackColor = lngGreen
        End If
    End Sub

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    Pretty sure seen this question before. I don't think can do this with a normal combobox.

    Options I know of: a form designed to look like listbox or a listview https://www.tek-tips.com/faqs.cfm?fid=6027
    Last edited by June7; 05-27-2020 at 03:37 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.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Text isn't a data type, you want String.

    Like June7, I don't think you can get the selections to be different colors when dropped down. You can certainly color the selected value, and Conditional Formatting might be easier.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Quote Originally Posted by pbaldy View Post
    Text isn't a data type, you want String.

    Like June7, I don't think you can get the selections to be different colors when dropped down. You can certainly color the selected value, and Conditional Formatting might be easier.

    I will research conditional formatting...thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem. Your code might work, but will set all records according to the selected record on a datasheet form, which probably isn't what you want. Formatting code like that only works well on a report, not a form (to get different formats on each record).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 21
    Last Post: 02-16-2017, 03:14 PM
  2. Replies: 2
    Last Post: 04-09-2016, 01:23 PM
  3. Replies: 3
    Last Post: 03-02-2016, 06:05 PM
  4. Color box with tables values
    By SaPires in forum Programming
    Replies: 1
    Last Post: 10-21-2014, 12:49 PM
  5. Combobox setting other combobox values problem
    By maxmaggot in forum Programming
    Replies: 8
    Last Post: 06-30-2013, 07:18 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