Cancel Dropdown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Combo box from which a customer code can be selected which then
fills a number of other controls using the AfterUpdate event. The Auto
Expand property is also set on. I am using the Dropdown method with the
OnChange event so that as soon as the first letter is typed the drop down
list appears. The problem with this for me is that the list then covers the
other controls that have just been filled. What I would like to do is make
the drop down list disappear after an item has been selected from the list
probably as part of the AfterUpdate Event Procedure. At the moment it only
disappears when the control looses the focus.

Thank you in advance for any suggestions

Cheers,
 
The problem is that you have the Dropdown method executed in the Change
event. When you make a selection, the drop down closes; however, the
selection also triggers the Change event which reopens the drop down.

Once the drop down is open, you probably don't need to open it again unless
you clear the combo box and start over. Try

If Len(Me.cboMyCombo.Text) <= 1 Then
Me.cboMyCombo.DropDown
End If

This should prevent the drop down from still being open as long as the text
in the selection is longer than one character. Another option would be to
open the drop down in the GotFocus event of the combo box.
 
Thanks Wayne,
I thought this would solve the problem but with AutoExpand set to on a full
6 character code is displayed and the auto selection simply changes as more
characters are typed so now the Dropdown never activates.

I need to deactivate the Dropdown after a selection is made. Any more
thoughts?

Thanks again
 
In that case, you'll need a "flag" variable that you set when you type in
the first character and clear if you clear the combo box. Use this flag as
an indicator to drop down the list.

Example (Change event):
Static bolFlag As Boolean
If Len(Me.cboMyCombo.Text) > 0 Then
If Not bolFlag Then Me.cboMyCombo.DropDown
bolFlag = True
Else
bolFlag = False
End If

You need the variable Dim'ed as Static so that its value will be remembered
as long as the form is open.
 
Thanks Wayne,

I still can't get it to do exactly what I would like. The drop down works
fine and disappears when a selection is made but the Auto expand doesn't work
properly. It simply fills the combo box with the first record in the list
which starts with the same character as the first character typed and won't
allow any more characters to be typed so as to move closer to the required
selection in the list.

I would like yhe auto expand to work normally as well if possible. Is this a
big ask?

Cheers,
 
Wayne,
My apologies,

It works fine, I had entered an input mask so that all etries were
capitalised (because all the reords in the list are) and this has caused the
problem. Ican live with lower case entries.
Thanks again.
 
Back
Top