Hi,

I am using MS access database with ADO control in VB.

I want to display only those names in the combo box when I type a first letter in the combo box using visual basic.

For Eg, When I type letter 'm' , the combo box should give a list of those names starting with letter m. Similarrly if I type "k" , it should givethe list of names starting with letter k. The names are to be retrieved from access database using ado control.

How can I do this?

Can anyone help me.

thanks

pkatt

Hi,

I am using MS access database with ADO control in VB.

I want to display only those names in the combo box when I type a first letter in the combo box using visual basic.

For Eg, When I type letter 'm' , the combo box should give a list of those names starting with letter m. Similarrly if I type "k" , it should givethe list of names starting with letter k. The names are to be retrieved from access database using ado control.

How can I do this?

Can anyone help me.

thanks

pkatt

First of all:
If the combobox is exploded, and you press any letter you go automatically to to the first occurence of your list.
Another solution is to fill the content of the combobox every time again.
I use next example. Everytime I start a form, I fill the combobox again with a new query.

Set dbsFotodatabase = OpenDatabase "D:\Fotobeheer\Fotodatabase.mdb")
Set rstPlaats = dbsFotodatabase.OpenRecordset("select distinct plaats from Blad1")
If rstPlaats.RecordCount > 0 Then
rstPlaats.MoveFirst
frmPreview.cboPlaats.AddItem "Alle"
Do
If rstPlaats.Fields("plaats").Value <> "null" Then
frmPreview.cboPlaats.AddItem rstPlaats.Fields("plaats").Value
End If
rstPlaats.MoveNext
Loop Until rstPlaats.EOF
End If

Thanks. but this not what I was looking for. I am able to load the names onto the combo box when loading form. But, After loading, if I type the first letter of the name in the combo box, the drop down list should show all names starting with the letter I have typed. For eg,

If I type m, the combo box should show,

Mickey
Mke
Mariam

Any Ideas??

thanx
pkatt

Thanks. but this not what I was looking for. I am able to load the names onto the combo box when loading form. But, After loading, if I type the first letter of the name in the combo box, the drop down list should show all names starting with the letter I have typed. For eg,

If I type m, the combo box should show,

Mickey
Mke
Mariam

Any Ideas??

thanx
pkatt

You can use cboList_keyPress(KeyAscii As Integer) and use the pressed letter to assemble echt time a new list again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.