Highlight selected records in dropdown box (1 Viewer)

Gismo

Registered User.
Local time
Today, 12:35
Joined
Jun 12, 2017
Messages
1,298
Hi all,

I have a form where I select the Supplier
In the product dropdown box, the product for this preferred supplier is listed on the top of the drop down box

When the product dropdown list is selected and the supplier selected is the preferred supplier, I would like to highlight all the products for the supplier

Is this possible?

1676759330103.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:35
Joined
Feb 19, 2013
Messages
16,612
Assuming you mean products listed in a form then I would think so using conditional formatting
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:35
Joined
May 21, 2018
Messages
8,529
That is not clear to me what you want to do. If I select "National Water", I assume you want to limit the selections in the list to products made by national water. I assume national water is not in the pepper and bacon business. That would be a "Cascading Combobox"
 

June7

AWF VIP
Local time
Today, 01:35
Joined
Mar 9, 2014
Messages
5,472
Last edited:

Gismo

Registered User.
Local time
Today, 12:35
Joined
Jun 12, 2017
Messages
1,298
That is not clear to me what you want to do. If I select "National Water", I assume you want to limit the selections in the list to products made by national water. I assume national water is not in the pepper and bacon business. That would be a "Cascading Combobox"
No I dont want to limit the product list
If a product has a preferred supplier and the supplier is selected, the products for this supplier would be sorted to the top of the combo box
only the products with the selected supplier must be highlighted
The balance of the product available for any supplier will be below but not highlighted
 

Josef P.

Well-known member
Local time
Today, 11:35
Joined
Feb 2, 2023
Messages
826
Color highlighting is not possible with an Access.Combobox.
You could create an additional column and insert a text marker in it or edit the text itself.

Code:
Water (...         | *
Advertising - ...  | *
Advertising - ...  |
or
Code:
* Water (...
* Advertising - ...
Advertising - ...
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 10:35
Joined
Feb 19, 2013
Messages
16,612
Or since the rowsource will be a union query include a third select that puts a line between the other two selects
 

GPGeorge

Grover Park George
Local time
Today, 02:35
Joined
Nov 25, 2004
Messages
1,867
Hi all,

I have a form where I select the Supplier
In the product dropdown box, the product for this preferred supplier is listed on the top of the drop down box

When the product dropdown list is selected and the supplier selected is the preferred supplier, I would like to highlight all the products for the supplier

Is this possible?

View attachment 106553
After reading through the discussion, I think I have a suggested solution.

You can use the idea presented by Josef P, in conjunction with an Immediate If in the query providing records to the second combo box, the one listing all Supplier as called out in your screenshot..

This is air code since I can't see that query:

SELECT S.SupplierID, SupplierName: Iif(S.SupplierID = TempVars!lngSupplierID, "*", "") & S.SupplierName
FROM tblSupplier AS S

Note that the conditional either puts an asterisk in front of the supplier name or not, depending on the value of a tempvar.

The tempvar is set in the combo box, using its AfterUpdate event.

Code:
Private Sub cboSupplier()

    Tempvars.Add "lngSupplierID", Nz(Me.cboSupplier.Column(0),0)
    Me.cboYourOtherComboBoxNameGoesHere.Requery
End Sub

Each time you change a value in the combo box on the header, it updates the tempvar and then requeries the other combo box to highlight the selected supplier.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:35
Joined
Feb 19, 2002
Messages
43,275
Here's a listbox and combo
AccColorListOrCombo.JPG
sample I picked up somewhere. The zip includes a database and a word doc.
 

Attachments

  • ColorListboxes.zip
    55.9 KB · Views: 91

CJ_London

Super Moderator
Staff member
Local time
Today, 10:35
Joined
Feb 19, 2013
Messages
16,612
doubt that will work for the OP's requirements - the colour is based of the format properties. For numbers (which includes dates and booleans) they are set depending on whether the value is positive, negative, zero or null. For strings the options are only not null or null. Either way won't work in a combo anyway.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:35
Joined
Feb 19, 2002
Messages
43,275
We are trying to do something that Access does NOT directly support.
The sample I posted also works in a combo.

A cascading combo seems to be the most rational solution given our lack of ability to easily control color in this context.
 

Users who are viewing this thread

Top Bottom