multi select combobox

R

Rob Oldfield

I don't think so, but then I also don't understand what you mean. A combo
(the way that I think of them anyway) will allow you to pick an entry and
then display it in the control. How do you expect it to display multiple
selections?
 
D

Duane Hookom

You can use a multi select list box. I you want this control to shrink to
display only a single value and take up less space on your form, you can use
some mouse event code. Consider list box "lboEmployees" with a rectangle
control around the outside "boxShrink"
|=boxShrink==|
| Employees |
| Bob |
| Mary |
|==========|
When designing the form, make the list box display only one record and place
the box around the control and label and make the Line/Border width of the
boxShrink 6 points. Make the boxShrink color Transparent and send the
control to the Back. Then add code to the form as noted below. When your
mouse moves over the list box, it will expand to show all values. You may
want to limit this expansion to a smaller size. When the mouse moves out of
the list box and crosses the boxShrink control, the list box and boxShrink
will shrink.

'==== begin code =======
Option Compare Database
Option Explicit
Const intItemHeight As Integer = 230

Private Sub boxShrink_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lboEmployees.Height = intItemHeight
Me.boxShrink.Height = intItemHeight + 100
End Sub

Private Sub lboEmployees_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim intItemCount As Integer
Dim dblMaxHeight As Double
intItemCount = Me.lboEmployees.ListCount
dblMaxHeight = intItemCount * intItemHeight
If Me.lboEmployees.Height <> dblMaxHeight Then
Me.lboEmployees.Height = dblMaxHeight
Me.boxShrink.Height = dblMaxHeight + 300
End If
End Sub
'==== end code =======
 
M

mcnewsxp

what kind of control is boxShrink?

Duane Hookom said:
You can use a multi select list box. I you want this control to shrink to
display only a single value and take up less space on your form, you can
use
some mouse event code. Consider list box "lboEmployees" with a rectangle
control around the outside "boxShrink"
|=boxShrink==|
| Employees |
| Bob |
| Mary |
|==========|
When designing the form, make the list box display only one record and
place
the box around the control and label and make the Line/Border width of the
boxShrink 6 points. Make the boxShrink color Transparent and send the
control to the Back. Then add code to the form as noted below. When your
mouse moves over the list box, it will expand to show all values. You may
want to limit this expansion to a smaller size. When the mouse moves out
of
the list box and crosses the boxShrink control, the list box and boxShrink
will shrink.

'==== begin code =======
Option Compare Database
Option Explicit
Const intItemHeight As Integer = 230

Private Sub boxShrink_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lboEmployees.Height = intItemHeight
Me.boxShrink.Height = intItemHeight + 100
End Sub

Private Sub lboEmployees_MouseMove(Button As Integer, Shift As Integer, X
As
Single, Y As Single)
Dim intItemCount As Integer
Dim dblMaxHeight As Double
intItemCount = Me.lboEmployees.ListCount
dblMaxHeight = intItemCount * intItemHeight
If Me.lboEmployees.Height <> dblMaxHeight Then
Me.lboEmployees.Height = dblMaxHeight
Me.boxShrink.Height = dblMaxHeight + 300
End If
End Sub
'==== end code =======
 
M

mcnewsxp

not bad.
problem is my listbox or combobox is part of a detail line on a continuous
form so the detail line expands with the listbox. no problem to resize with
your boxShrink cotrol, but but it looks wierd and because there are several
listbox controls on the screen they all look a little shakey. this'll come
in handy somewhere, tho.
thanks,
mcnewsxp.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top