Combo Box Fore Color Not Changing in One Column (1 Viewer)

BlingGirl

New member
Local time
Yesterday, 20:36
Joined
Apr 11, 2020
Messages
19
I have a search as you type combo box that has one column that is not changing text color.
I tried the format painter copying one combo box to try to apply the formatting, but it doesn't work.
I tried using a different fore color, but that didn't work.
I check table settings and query settings, but nothing going on there.
I created a new form, and the field performed exactly the same.
I deleted the field, copied a combo box that had the settings I wanted, changed the formatting, renamed it, and set the events, it still did the same thing.
I deleted the field again, created a new field by adding a new combo box control, and added the property, it still did the same thing.

I went back to the property settings and changed the width of the columns so they would all be visible. (I just want the first column to show on the form.)

The first column is black, and columns 2 & 3 are blue. I am trying to make them all blue.

Any clue what would cause this?

I feel like it has to be in the code. Unfortunately, I am new to coding and have no idea how to troubleshoot code that does not reference any formatting whatsoever yet is affecting formatting.

Below is the only code for the combo box. I have attached a photo of the field on the form and a photo of the field's property settings.

Code:
Private Sub PropertyID_AfterUpdate()
    Me.Property.Value = Me.PropertyID.Column(0)
End Sub

Private Sub PropertyID_Change()
    Dim SQL As String
        If Len(Me.PropertyID.Text) > 0 Then
            SQL = "SELECT Property.PropertyName, Property.PropertyID, Property.InActive FROM [Property] WHERE (((Property.InActive)=False)) AND (((Property.PropertyName) Like ""*" & Me.PropertyID.Text & "*"")) ORDER BY Property.PropertyName;"
        Else
            SQL = "SELECT Property.PropertyName, Property.PropertyID, Property.InActive FROM [Property] WHERE (((Property.InActive)=False));"
        End If
            Me.PropertyID.RowSource = SQL
            Me.PropertyID.Dropdown

End Sub
Screenshot 2022-05-22 133644.png
3-PropertyIDSettings.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:36
Joined
Sep 21, 2011
Messages
14,221
No idea TBH.
I just took a combo that displays more than one column, use the colour palette to choose a colour, and all columns were that colour?

Dark Blue is #1F497D, not what you have there? Access 2007 does not have those options anyway.

FWIW any time I am repeating code, generally there is a better way, easier to edit if need be. So I would code your sub as

Code:
Private Sub PropertyID_Change()
Dim strSQL As String
strSQL = "SELECT Property.PropertyName, Property.PropertyID, Property.InActive FROM [Property] WHERE (((Property.InActive)=False))"

    If Len(Me.PropertyID.Text) > 0 Then
        strSQL = strSQL & " AND (((Property.PropertyName) Like ""*" & Me.PropertyID.Text & "*"")) ORDER BY Property.PropertyName"
     End If
    Debug.Print strSQL
     Me.PropertyID.RowSource = strSQL
     Me.PropertyID.Dropdown

End Sub
I generally also use Debug.Print strSQL after it is populated to check my syntax. Then comment out when working.

Just my way of thinking.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 04:36
Joined
Feb 19, 2013
Messages
16,603
just a thought try changing the order of columns - put the bound column first and adjust your column widths

I note that in the properties provided there is no rowsource and column widths are set to 1,0,0 which is not what is displayed in the form screenshot.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:36
Joined
May 7, 2009
Messages
19,228
I check table settings and query settings, but nothing going on there.
you did not check enough.
you can add Color formatting on the field.
to show a Short Text field as Red, use Format:

@[Red]
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:36
Joined
Feb 28, 2001
Messages
27,131
If this is a screen capture then you appear to have an error.

Code:
Private Sub PropertyID_AfterUpdate()
    Me.Property.Value = Me.PropertyID.Column(0)
End Sub

Should that perhaps be Me.PropertyID.Value = Me.....?

But then, it gets trickier since as you have it written, .Property is a keyword - for the generic name by which you abstractly reference a property. Access can get a little crazy if you use keywords loosely.

I'm not sure what that sequence was intended to do, but if you really meant Me.PropertyID.Value, that might be superfluous. If Column 0 for the combo box is considered as the Bound column, then the .Value of the combo after selection is just Me.PropertyID because the default for that case would be the selected row's bound column value - without the need for referring to .Value at all. And that is because .Value is the default property when referring to controls that actually HAVE a value.

By the way, since that was your first post: Hello and welcome to the forum.
 
Last edited:

Users who are viewing this thread

Top Bottom