PeterM said:
I have a combobox on a form in Access 2003. Is there a way to cause
the drop down portion of the combobox to display without clicking on
the arrow on the combobox? I want to emulate a menu using a combobox
and I'll use the MouseMove event for the combobox to execute a
subroutine to cause the dropdown portion to appear.
Any help would be appreciated...thanks!
You can cause the combo box's list to drop down by calling the control's
DropDown method; e.g.,
Me.cboMyCombo.DropDown
but -- and here's the rub -- you can only do that when the control has
the focus. Just moving the mouse over it won't give it the focus unless
you use the MouseMove event to set the focus to it. That's probably not
what you want to do, as it would make the control into a sort of "focus
magnet", and you'd need elaborate code to remedy that behavior. I
suppose you could use the MouseMove events of all the other controls on
the form to set the focus to them. That could work, if all you really
want to do is implement a menu system.
Another approach that occurs to me is to have a pair of controls, a text
box and a list box, overlaid on each other, and have only one visible at
a time. The text box would be set up as a calculated control to show
whatever is selected in the list box. When you move the mouse over the
text box, you hide the text box and show the list box. When you make a
selection on the list box, you show the text box and hide the list box.
When you move the mouse over any other portion of the form, you hide the
list box if it is currently visible and show the text box. The code
here would need to check whether the list box or text box has the focus
at the moment you want to hide it, and take appropriate action, because
you can't hide the control that has the focus.
Hmm, now that I write that out, I begin to think the combo box approach,
even with the necessary workarounds, would be simpler. None of this is
as simple as you'd like it to be.