retract dropdown for combobox

J

joeeng

Is there a way to programmatically retract the dropdown list for a combobox
on a form?
 
J

Joel

See VBA help

ShowDropButtonWhen Property

fmShowDropButtonWhenNever 0 Do not show the drop-down button under
anycircumstances.
fmShowDropButtonWhenFocus 1 Show the drop-down button when the control has
the focus.
fmShowDropButtonWhenAlways 2 Always show the drop-down button.
 
J

joeeng

Thanks, Joel
However, this is not quite what I am looking for. I would like to hide
(retract) the dropdown list itself (not the button) when the user types
something in the combobox that does not match anything in the dropdown list.
I have worked out the procedure, but I cannot figure out how to get the
dropdown list to hide itself. Dropdown method makes it appear, but what
makes it retract?
 
J

Joel

What about disable the combobox? You can check the properties window in the
userform (select combobox) to see all the options. You can change them
manual in the property window so you can see the effectr of each change
before adding code to perform same operation. If the property window doesn't
display the go to menu View to add the window.
 
J

joeeng

Joel,
Based on your idea, a simple workaround worked.

Combobox.Enabled=False
Combobox.Enabled=True
Combobox.SetFocus

This hides the dropdown list and returns to the combobox exactly where the
user left off typing the new entry.

Thanks for the idea.
 
J

joeeng

I tried setting listindex to -1 and this is what I found. Setting the
listindex to -1 merely removes the selection focus from the dropdown. It
does not hide the dropdown list.
 

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