Separator line in combobox.

ahmad_rmh

Member
Local time
Today, 16:47
Joined
Jun 26, 2022
Messages
243
Dear Experts,

Kindly suggest coding or way to insert separator line in combobox.
 
Like i have attached image, i want separator line in combobox, and there is another option Add new, when click on add new, it opens the customer form to enter new customer. this screenshot has been taken from quickbooks.
 

Attachments

  • Screenshot_20220630-224002_YouTube.jpg
    Screenshot_20220630-224002_YouTube.jpg
    841.1 KB · Views: 124
Last edited:
ms access doesn't have combobox separator.
neither does it allow image on the combo.
 
only way you can do that is to use a subform. Set it just below a textbox with a height of 0. When the textbox gets to focus, set the height to what you require. When a user selects an item or the subform loses focus, set the focus back to the textbox and reduce the subform height back to 0. If an item has been selected that is different to the textbox, update the textbox with the new item.

With regards the image, either have that as a separate image control to the left of the textbox, or use a button (which can be made to look like a textbox) instead of a textbox - but then you will be updating the button caption and picture instead.

and for your separator on your continuous subform, use an unbound textbox with a small height and no border and use conditional formatting to set a colour to either show or blend with the back colour conditional on something - per your example perhaps along the lines of

framecolour='white' or framecolour='No Frame'
 
Dear Experts,

Kindly suggest coding or way to insert separator line in combobox.
Depending on the rowsource, you can finesse a separator line into list and combo boxes sometimes. In a Union query, you can add the separators as separate SELECTs with the appropriate markers to indicate where in the final list they'll be displayed. However, this would only work, I suspect, with a stable list of items. The screenshot you displayed, which is based on a fixed color pallete, could be made to work this way.


Code:
SELECT "Marker" AS Section
    ," " AS NAME
    ," --Forms--" AS DisplayName
    ,0 AS SortORDER
FROM MSYSObjects
UNION
SELECT "Form" AS Section
    ,MSYSObjects.NAME
    ,Replace(Replace([Name], "frm", "") , "_", " ") AS DisplayName
    ,1 AS SortOrder
FROM MSYSObjects
WHERE ( MSYSObjects.NAME <> "frm_Main_Menu"
    AND Left(MSYSObjects.NAME,2) <> "Z_"
    AND Left(MSYSObjects.NAME,4) <> "sfrm"
    AND MSYSObjects.Type = - 32768 )
UNION
SELECT "Marker" AS Section
    ," " AS NAME
    ," --Reports--" AS DisplayName
    ,2 AS SortORDER
FROM MSYSObjects
UNION
SELECT "Report " AS Section
    ,MSYSObjects.NAME
    ,Replace(Replace([Name], "rpt", "") , "_", " ") AS DisplayName
    ,3 AS SortOrder
FROM MSYSObjects
WHERE ( MSYSObjects.NAME <> "frm_Main_Menu"
    AND Left(MSYSObjects.NAME,2) <> "Z_"
    AND MSYSObjects.Type = - 32764 )
UNION
SELECT "Quit" AS Section
    ,"Quit" AS NAME
    ,"Quit" AS DisplayName
    ,4 AS SortOrder
FROM MSYSObjects
ORDER BY SortOrder, DisplayName
1656508989202.png
 
I was looking for a solution for a separator line in a Combo but the Search wasn't working.
So in the meantime I cobbled together a cheap and nasty solution of sorts and add it here in case it may be of interest.

Code:
1. Me!Combo109.RowSource = "' ';'Census';'Gazetteer';'Notes'" << normal Combo options with a blank first entry.

2. Me!Combo109.RowSource = "' ';'Census';'Gazetteer';;'Notes'" << the extra ; forces a blank line with a Null value after Gazetteer

3. Me!Combo109.RowSource = ";'Census';'Gazetteer';'------------------';'Notes'" << the first ; at the start forces a blank line with a Null value and after Gazetteer a definite line instead or a blank.

4. Me!Combo109.RowSource = ";'Census';'Gazetteer';;'Marriages';'Notes'" << the extra ; drives a blank line at the start and after Gazetteer both returning a Null entry

However, you will need to control the Error 94: Invalid Use of Null after any additional semicolons which return Nulls
The selection in line 2 has an extra ; after Gazetteer.
In line 3 a blank initial option, followed by a continuous line after Gazetteer, which you will need to handle in your code.
Line 4 shows a blank as the first option with a ; as well as two ;; after Gazetteer, the invalid ; both returning Nulls.
 
A better solution would be cascading combos if your problem is anything like that of the OP. Storing both (or all) levels means you won't need code to manipulate the form to position the parent combos to the correct item in the Current event.
 
Images can be added using an "Image Combobox" "mscomctllib"
Seperators can be done using "List View"
A tree view can do seperators and images.

These are all Active X controls that require some VBA knowledge and are not well documented, but not super hard to use.
imgage combo class.PNG


Image Combobox
ImageCombo.png


List view with colors
Listview with colors.PNG


Tree view without Images (but can have them) and unlimited Dividers. Demos selecting a recipe from a tree.
tree.png

I can not attest if the listview and image combo work in both 32 and 64 bit, but the treeview would
 

Users who are viewing this thread

Back
Top Bottom