Limit records in combo box

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

Guest

My goal is to have the user start typing a customer's name in the combo box
then have the same combo box only show records to choose from what the user
started typing. I have the following code which I got from a previous thread
- I'm still able to start typing a customer's name and the first customer
with those letters populates the combo box - but when I click on the down
arrow to view the rest of the customers that start with those characters, it
takes me to the last record of which the combo can hold (the 65, 653
record??). So If I started typing "TEX", it'll show "TEXAS..." but when the
drop down is clicked it shows customers that start with J. Please help. :)

Dim sCombo26 As String
Const conCombo26Min = 1
Function ReloadCombo26(sCombo26 As String)
Dim sNewStub As String ' First chars of COMPANY_NAME.Text

sNewStub = Nz(Left(sCombo26, conCombo26Min), "")
' If first n chars are the same as previously, do nothing.
If sNewStub <> sCombo26 Then
If Len(sNewStub) < conCombo26Min Then
'Remove the RowSource
Me.Combo26.RowSource = "SELECT CL_NAME, CL_ID,
BRCH_LOCATION_CODE FROM Qry_Customer_Lookup WHERE (False);"
sCombo26 = ""
Else
'New RowSource
Me.Combo26.RowSource = "SELECT CL_NAME, CL_ID,
BRCH_LOCATION_CODE FROM Qry_Customer_Lookup WHERE (Combo26 Like """ & _
sNewStub & "*"") ORDER BY CL_NAME, CL_ID, BRCH_LOCATION_CODE;"
sCombo26Stub = sNewStub
End If
End If
End Function
 
Auto Expand for the combo box is currently on.

The only thing the combo box isn't doing is only displaying those records
that start with what the user types into it when the drop down is clicked on
- it still only displays the first 65K records or so.
 
Okay - Finally got this code to work...for the most part. The problem I have
now is when the user first tabs to the field and starts typing a customer
name absolutely nothing happens. It's only when the user backs out of the
field and tbas back into the comobox and types again that the list will
populate.

Any ideas?
 
Hi, Jeff. I'm entering 3 characters as the code specifies. The code works
perfectly - the second time to type something in the combo box.
 

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

Back
Top