Info on List boxes

N

nutmeg

Hello,

I have various forms that have drop down lists to pick from, some value,
some table/query. I would like to investigate the possibility of changing
them so that the user can hover the mouse over the list box, it will drop
down and show the related lists on another drop down beside it. I see this
action on most microsoft screens but can't find the right words to describe
it I guess, so can't find the correct information. I have able to find
'drilldown' but that isn't exactly what I want, I just want to see the
attached list for selection using the mouse. Can anyone let me know how this
is done.

Thank you,
IEJ
 
R

Rob Parker

You can use the dropdown method of a combobox to open its list when the
mouse moves over a control (any control on the form) by putting the
following code in the MouseMove event of that control:

Private Sub controlName_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
cboxMyCombo.SetFocus
cboxMyCombo.Dropdown
End Sub

However, using this as the basis of a mousehover action isn't really simple
(and the hover event used to display a controltip is not accessible). Any
movement of the mouse across the control will trigger this event, so to get
it to work as a hover you'll need to check the X and Y positions several
times to make sure the mouse is actually hovering over the control, rather
than merely passing over it. Another important point is that, for the
DropDown method to work, the combobox which you want to open must have
focus. In the code above, the first line does that, but if the combobox
already has focus this will generate an error so you'll need to test for
this first or else trap the error; if the .SetFocus is not used and you
apply the .DropDown, you'll get a different error (again, test first or
trap).

You'll probably find things easier if you open the related combobox in a
different event - perhaps GotFocus or AfterUpdate of the first control; the
AfterUpdate would be a good choice, since you are probably using this
already to change the recordsource of the related combobox. Whichever way
you do it, the related combobox will have focus after it is opened - if you
don't want that, then you can't do it at any way

HTH,

Rob
 

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