9 Years
Discussion Span
Last Post by hkdani


Microsoft Access?

typing in the combo

I take it you mean searching through list that was loaded into the Combo Box.

You just have to extract the value from the current text in the combo, determine the size of the list in the combo, and then do a search using a loop until you find the value that matches.

Once you've found a match, you can stop at that point and determine the index at that value.

But you have to raise some type of event to determine when to perform the search. A command button would probably be the easiest:

Private sub Command1_Click()
   ' 1. Extract your typed text
   ' 2. Loop through the combo list to find the matching value and establish index values, etc.
  ' 3. Code to do whatever you want with that information.
End Sub

Sir, i wanted to search in vb. and the entries are there in the combo and we want that as we enter the letters. The matching results are sorted out of the rest. For example if we right mu in combo then muslim, musa are left in the combo.


The matching results are sorted out of the rest.

I take it you mean you want to remove the list entries that don't match what you've typed in?

Your first step might be to save the complete list in some sort of array.

Option Explicit
Dim strPeople() As String
Dim intListCount As Integer

Private Sub Form_Load()
Dim IntCounter As Integer
intListCount = List1.ListCount
ReDim strPeople(intListCount - 1)
For IntCounter = 0 To (intListCount - 1)
   strPeople(IntCounter) = List1.List(IntCounter)
End Sub

Use this a master list to fill the combo box as you type. I wouldn't suggest filling the combo box to start with, but build your list first using your values from Access.

Use the KeyPress Event in the Combo Box to use with string search functions to fill your list as the user types.

But in essence each time he types, put code in the KeyPress Event to build the list for the combo box.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.