Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filtering a combo box on entering letter 1

Status
Not open for further replies.

Zeroanarchy

Technical User
Jun 11, 2001
630
AU
what I am trying to do is limit the combo box on entry ie. press "a" only entries starting with "a" show on the combo box drop down list, and if you select "ab" show only entries starting with "ab" and so on and so on and if they go back and select "c" refresh and only show list starting with "c".

hope this makes scence. any help greatly appreatiated.

this is what I have got so far.

Row Source: SELECT DISTINCTROW names.[Surnames], names.[first Names], names.[MiddleName] FROM names ORDER BY names.[Surnames Name];

Code on change:
Me.Combo224.RowSource = "SELECT DISTINCTROW names([Surnames_Name], " & Len(Combo224.Text) & ") Like '" & Combo224.Text & "*'"
Me.Combo224.Requery


Zero
 
Hi, comboboxe´s do it by default, if you type "a" or "A" you have a filter to all strings begining with "a" and ......... Best Regards

---
JoaoTL
mail@jtl.co.pt
My MS Access Site:
 
The idea is that if A is selected only show record in the combo box starting with a if ab is selected only show record in the combo box starting with ab and so on.
the default that Access forms use is that id you select A it will highlight the first record starting with a but all other options still appear in the list.

zero
 
What's the Len for? Delete it and it should be OK.

Craig
 
Craig tried it still no go, looks like there is something else majorly wrong.

Code on change:
Me.Combo224.RowSource = "SELECT DISTINCTROW names([Surnames], " & (Combo224.Text) & ") Like '" & Combo224.Text & "*'"

it comes up with missing syntex.
 
Combo Box that looks at 2 or more tables
faq181-855

Don't know if this could help you, but thought I'd pass it on. hth

Learn what you can and share what you know.
 
Not sure why you would want this, but it sounded interesting. Here is a little something I came up with.

1. Declare a string variable at the module level (Option Explicit) I will call my variable strHold.

2. In the combo box's Key Press event put the following. I called my combo box DaBox.

Private Sub DaCombo_KeyPress(KeyAscii As Integer)

If (KeyAscii >= 48 And KeyAscii <= 90) Or (KeyAscii >= 97 And KeyAscii <= 122) Then

strHold = strHold & Chr(KeyAscii)
MsgBox strHold
DaCombo.RowSource = &quot;SELECT MYFIELD FROM THETABLE WHERE MYFIELD LIKE '&quot; & strHold & &quot;*'&quot;
Else
DaCombo.RowSource = &quot;SELECT MYFIELD FROM THETABLE&quot;
strHold = &quot;&quot;
End If

End Sub

Each time you hit a key, the procedure checks to see if it falls in the alpha or numeric range of keys. If so, it starts to build a string variable and uses that variable along with a wildcard to reset the row source. If it is not an alpha num, it resets the string list. This may need some tweeking but it is the jest of what you asked. Hopefully you can run with it from here. I tried it and it works.

Good luck...

ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top