Combo narrow list to letters typed

G

Guest

Hello -

I'm trying to narrow down a list of states as a user types letters in. The
states are two-letter abbreviations, capitalized. I have the following code
which does sort of do it, but if someone types in a lower case letter, it
puts the lower case in the combobox. Also, I had put this into the
cboState_change event, which is obviously wrong, because it wipes out the
RowSource code that is set in the properties.

In other words, I need it to:
1. Capitalize the abbreviation even if a user types lower case
2. Find out the best place to put the code

Dim strText As String
strText = Nz(Me.cboState.Text, "")

If Len(strText) > 1 Then
Me.cboState.RowSource = "Select State from " & _
"tblDeclaration " & _
"Where State like '" & strText & "*'"

Me.cboState.Dropdown

End If

Seems to me this should be a "textbook" solution, but I wouldn't know what
textbook it would be in -- certainly not one of mine!

Any help will be greatly appreciated!
 
G

Guest

You need no code. Set the AutoExpand property of the combo to Yes, and it
does that for you. It will not matter wheter a user types in a lowercase
character because they are not entering data, only selecting it.
 
G

Guest

Thanks, Klatuu!
--
Sandy


Klatuu said:
You need no code. Set the AutoExpand property of the combo to Yes, and it
does that for you. It will not matter wheter a user types in a lowercase
character because they are not entering data, only selecting it.
 

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