multiselect listbox

  • Thread starter gm6243 via AccessMonster.com
  • Start date
G

gm6243 via AccessMonster.com

Dear Friends,

I have a multi select listbox on a form. I am able to make multple selections
and generate a report based on the selection.
My problem is my multi select listbox has over 300 test codes(alphanumeric)
and it is very tedious to search thru the list to select specific codes.
My question is : Is there a way I can type a few alphabets and the code in
the list box. After selection I should be able to make the next selection in
the same way.

This would be a great help as I dont have to scroll thru the listbox to make
the selection

Any help is appreciated.

Thanks
Gimen
 
J

Jeanette Cunningham

Hi gm6243,
there is a 'search as you type', type of thing you can setup.
You need an unbound textbox. As the user types in the unbound textbox,
matching records show in the listbox.
To see an example of how this works, you can download the sample search form
from
http://allenbrowne.com/ser-62.html

the search box for Name shows this 'search as you type' behavior.
Use it as an example to do the same thing with your listbox.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Mr B

gm6243,

As is explained in Allen Brown's info, you will need to setup a combo box
that has the list of items that you want to search through. When you start
to typ in the combo box, Access will find the next matching item.

However, if you are going to use the selections made from a "multi-select"
list box for your report, then you will need to have the item found using the
combo box, become one of the "ItemsSelected" in the "multi-select" list box.

Try placing code like the following in the "After Update" event of your
combo box:

Dim lngItemId As Long
Dim i As Integer

lngAgencyId = Me.cboFindAgency
For i = 0 To Me.NameOfYourControl.ListCount - 1
If Me.NameOfYourControl.ItemData(i) = lngItemId Then
Me.NameOfYourControl.Selected(i) = True
End If
Next i

You will of course need to change the "NameOfYourControl" to the acutal name
of your combo box control for this to work.

When you have made a selection in the combo box and completed that selection
by pressing the tab or enter keys, the item you selected from the combo box
will be selected in you multi-select type list box.

--
HTH

Mr B
askdoctoraccess dot com


Jeanette Cunningham said:
Hi gm6243,
there is a 'search as you type', type of thing you can setup.
You need an unbound textbox. As the user types in the unbound textbox,
matching records show in the listbox.
To see an example of how this works, you can download the sample search form
from
http://allenbrowne.com/ser-62.html

the search box for Name shows this 'search as you type' behavior.
Use it as an example to do the same thing with your listbox.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
G

gm6243 via AccessMonster.com

Thank you both for the quick respose. I will implement the suggestion and
try.

Appreciate your adivice.

Mr said:
gm6243,

As is explained in Allen Brown's info, you will need to setup a combo box
that has the list of items that you want to search through. When you start
to typ in the combo box, Access will find the next matching item.

However, if you are going to use the selections made from a "multi-select"
list box for your report, then you will need to have the item found using the
combo box, become one of the "ItemsSelected" in the "multi-select" list box.

Try placing code like the following in the "After Update" event of your
combo box:

Dim lngItemId As Long
Dim i As Integer

lngAgencyId = Me.cboFindAgency
For i = 0 To Me.NameOfYourControl.ListCount - 1
If Me.NameOfYourControl.ItemData(i) = lngItemId Then
Me.NameOfYourControl.Selected(i) = True
End If
Next i

You will of course need to change the "NameOfYourControl" to the acutal name
of your combo box control for this to work.

When you have made a selection in the combo box and completed that selection
by pressing the tab or enter keys, the item you selected from the combo box
will be selected in you multi-select type list box.
Hi gm6243,
there is a 'search as you type', type of thing you can setup.
[quoted text clipped - 30 lines]
 

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