Auto scrolling in list boxes

  • Thread starter Thread starter Carol Grismore
  • Start date Start date
C

Carol Grismore

Is there a way to make the list box do what the combo box
will do -- keep scrolling through a list as the user
continues to type the value of the field?

For example, if the user types "c" in the list box, it
will scroll to the first occurrence of a member of the
list that starts with "c". If the user then types "e",
the list will scroll to an entry that starts with "e".

What I want it to do, if the user types "ce", is to scroll
to an entry that starts with "ce".
 
Nope. The list box just looks at the current key being typed.

You can set something up like this using a separate text box for the user to type in and then sync up the list box using a little
code.

This is described in the article at http://support.microsoft.com/default.aspx?scid=kb;en-us;218621 which also contains the necessary
code.

Good luck.

--

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, Access MVP, A+
Useful Metric Conversion #15 of 19: 5 dialogues = 1 decalogue
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Yes... kind of. It took me 30 minutes, but I figured one
way of doing it.

1) Create say 5 small text boxes and label them Text1 thru
Text5 and place them next to each other left to right and
flatten the Special Effect property.

2) Create the List box called List1 and place it beneath
the 5 text boxes.

3) ListBox: Click on the Row Source elepsis and create the
query which alphabetically lists the data you want. Start
with just one field to begin with. You can add other
fields after you get it working. Add the table to the
query and ONE field to the left column of the query grid.

In the second column add to the field name:
1: Left([Name],1)

In the third column add to the field name:
2: Mid([Name],2,1)

In the fourth column add to the field name:
3: Mid([Name],3,1)

In the fifth column add to the field name:
4: Mid([Name],4,1)

In the sixth column add to the field name:
4: Mid([Name],5,1)

In the Criteria of the Second Column enter:
Like [Forms]![FormName]![Text1] & "*"

In the Criteria of the Third Column enter:
Like [Forms]![FormName]![Text2] & "*"


In the Criteria of the Fourth Column enter:
Like [Forms]![FormName]![Text3] & "*"


In the Criteria of the Fifth Column enter:
Like [Forms]![FormName]![Text4] & "*"

In the Criteria of the Sixth Column enter:
Like [Forms]![FormName]![Text5] & "*"

To the following Text boxes 1 thru 5 enter the following
to their respective properties:

Text1:
Key Up:
DoCmd.GoToControl "Text2"

Text2:
On Enter:
Me![List2].Requery
Key Up:
DoCmd.GoToControl "Text3"

Text3:
On Enter:
Me![List2].Requery
Key Up:
DoCmd.GoToControl "Text4"

Text4:
On Enter:
Me![List2].Requery
Key Up:
DoCmd.GoToControl "Text5"

Text4:
On Enter:
Me![List2].Requery

Explanation:
You create what looks like one field but is really several.
When you enter a character, the focus goes to the next
field AND at the same time requeries the List box
filtering the entries based on what you entered into Text
Box 1. This sequentially filters the data as you enter
one letter/number into each of the 5 text boxes. Finally,
you do have to actually click on your selection in the
list box.

This works great for me, so if your having problems, I
suggest you copy and past the code I gave you and debug
from there.

You can add as many text boxes as you like and you can add
more fields to the List box once you get it working.

Good Luck.
 
Back
Top