Dropdown boxes - filtering alphabetically (1 Viewer)

Megacitizen

Registered User.
Local time
Today, 04:21
My form has a combobox recording the nation a team comes from when going to our Focus City, selected from a predetermined list. When I try to key in the first letter of the nation in question, the filter selects only the first nation in our list beginning with that letter, instead of all nations beginning with the letter.

Example - We have 4 nations on our list beginning with the letter "U" (Uganda, Uruguay, US Virgin Islands and USA). If I type in "U", only Uganda shows in the dropdown Box, if I type in "US" (intending to type "USA") only US Virgin Islands shows up. (Quote marks are mine btw)

Is there a code that will allow the form to display all 4 nations (or however many depending on the nation to be entered) as recorded by the user?
 

VilaRestal

';drop database master;--
Local time
Today, 12:21
A combobox can only display one item in its textbox area. It's only one line deep.

However, you can force it show the dropdown list using the DropDown method. In this case perhaps on the combobox's change event:

Code:
Private Sub Combo1_Change()
    If Len(Me.Combo1.Text) > 0 Then Me.Combo1.DropDown
End Sub
 

Megacitizen

Registered User.
Local time
Today, 04:21
Thanks for your suggestion.

I tried the code in the OnChange event but now it just shows a blank dropdown. I have set up a new combox using the relevant wizard. Should I be adding other lines to the code to get it to display the relevant data options?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:21
The Change event runs for every character typed into the control. I would use the control's on Dirty event which will only run once.
 

VilaRestal

';drop database master;--
Local time
Today, 12:21
Thanks for your suggestion.

I tried the code in the OnChange event but now it just shows a blank dropdown. I have set up a new combox using the relevant wizard. Should I be adding other lines to the code to get it to display the relevant data options?

I thought you already had a combobox that showed a list of countries.

The code does nothing to the rowsource of the combobox (the list behind it). Set that up as normal.
 

Megacitizen

Registered User.
Local time
Today, 04:21
Sorry, my mistake. I had changed a couple of Table headers and other relevant field names to help make writing a query code a bit simpler for myself (the old names were a bit long winded). However, I ended up corrupting the form so I deleted it and started again. I had forgotten to mention this. (insert hitting own head with cricket bat type smilie here)

Your "wizard" suggestion in another thread worked a treat though and made designing the combos in the new form so much quicker and simpler.
 

Users who are viewing this thread

Top Bottom