combo box indenting

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I have a situation in which there is a parent with many children that the
user wants to see inside of a combobox. The parent would show as normal in
the combobox but the children to that parent would be underneath and
indented. The sample below is what the users are looking for in the
combobox.

sample--------

parent
child
child
parent
child
parent
----------------
I can fill a combobox but I have never had to indent. Is that even
possible? If it is, how is it done?

Thanks for any help.

John
 
AFAIK, there's no Indent possible. However, perhaps you can simply put
spaces in front of the child records.
 
JohnE,

I don't know how many records you're having to deal with so this may not be
practical, but if you made the combobox row source type a value list you
could set the rowsource to something like the following where the string
value for the name of any child is preceded by a couple of spaces.

rowsource = "Parent";" Child1";" Child2";"Parent";" Child";"Parent"
 
JohnE said:
I have a situation in which there is a parent with many children that the
user wants to see inside of a combobox. The parent would show as normal in
the combobox but the children to that parent would be underneath and
indented. The sample below is what the users are looking for in the
combobox.

sample--------

parent
child
child
parent
child
parent


I do this kind of thing using a row source query along these
lines:

SELECT ParentName As DisplayField,
Null As Child,
ParentName & "/" As SortField
FROM Parents
UNION ALL
SELECT "", ParentName & "/" & ChildName, ChildName
FROM Children INNER JOIN Parents
ON Parents.ParentID = Children.ParentID
ORDER BY 2

Then set the combo box's BoundColumn = 2 and
ColumnWidths = 1;1;0

You will probably want to add some code to the combo box's
Before Update event that prevents users from selecting a
parent row:

If IsNull(Me.thecombobox) Then
Me.thecombobox.Undo
Cancel = True
Beep
End If
 
Back
Top