Multi-character AutoExpand Using Listbox

  • Thread starter JustAnotherGeek
  • Start date
J

JustAnotherGeek

I'm attempting to extend one of the features of a listbox in Access.

If I press a key (e.g. "G") while the listbox has the focus, the
listbox will automatically scroll to the first item in the list that
starts with the letter "G". The problem is that if I then press
another letter (say "R"), the listbox will scroll to the first item
that starts with the letter "R".

I would like to get the listbox to instead scroll the the first item
that starts with "GR".

Using some VBA code, I've managed to get this behavior to work fine --
almost. If I type "GR" while my listbox has the focus, it scrolls to
the first item that starts with "GR". However, the built-in listbox
functionality then runs and the listbox scrolls to the first item that
starts this the last letter I pressed.

So here's my question(s): Is there any way to disable the auto-scroll
feature of a listbox? If not, then has anybody else figured out a way
to get multi-character scrolling working with listboxes?

I'm using Access 2000 and/or 2003.

And my apologies in advance if this issue has been discussed already. I
looked but didn't find anything that looked like this.
 
K

Ken Snell \(MVP\)

Combo boxes have the behavior that you seek already built-in (AutoExpand
property). Can you use a combo box for your purposes?

I have not done any "playing around" with making listboxes behave the way
you want, sorry, so I don't have an "off-the-shelf" solution.

You might be able to use a textbox / listbox combination to let the user
type into a textbox the letters desired, then click button to fill the
listbox with the matching records.
 
M

missinglinq via AccessMonster.com

Ken is exactly right, why waste time re-inventing the wheel?
Combo boxes have the behavior that you seek already built-in (AutoExpand
property). Can you use a combo box for your purposes?

I have not done any "playing around" with making listboxes behave the way
you want, sorry, so I don't have an "off-the-shelf" solution.

You might be able to use a textbox / listbox combination to let the user
type into a textbox the letters desired, then click button to fill the
listbox with the matching records.
I'm attempting to extend one of the features of a listbox in Access.
[quoted text clipped - 21 lines]
And my apologies in advance if this issue has been discussed already. I
looked but didn't find anything that looked like this.
 
J

JustAnotherGeek

I wouldn't characterize this as reinventing the wheel. As far as I
know, combo boxes do not support having multiple items selected at one
time (a requirement for the application), which is why the listbox is
being used instead of the combo box. I'm just looking for a way to
have a single control that works a little like both, that's all.

The application that I'm modifying is very stable and has been in
production for over ten years. Until recently, the number of items
(and the distribution of the first character in each) in my listbox was
such that the canned (single-character autoexpand) functionality of the
listbox was acceptable. Recently, the number of items in the listbox
has increased dramatically, and in some cases over 100 items start with
the same letter. This has made the existing built-in functionality
unacceptable to my users.

If there is no satisfactory solution to my problem, then the UI for my
application will probably have to change signficantly, which is
something I'm trying to avoid for obvious reaons.

I was just hoping somebody else had found themselves in this situation
before, and could help me out so that I don't have to reinvent
anything.


Ken is exactly right, why waste time re-inventing the wheel?
Combo boxes have the behavior that you seek already built-in (AutoExpand
property). Can you use a combo box for your purposes?

I have not done any "playing around" with making listboxes behave the way
you want, sorry, so I don't have an "off-the-shelf" solution.

You might be able to use a textbox / listbox combination to let the user
type into a textbox the letters desired, then click button to fill the
listbox with the matching records.
I'm attempting to extend one of the features of a listbox in Access.
[quoted text clipped - 21 lines]
And my apologies in advance if this issue has been discussed already. I
looked but didn't find anything that looked like this.
 
D

Douglas J. Steele

Unfortunately, I think you're going to have to change your UI.

Even if the list box had the same AutoExpand capabilities as the combo box,
I don't see how you'd be able to use it in conjunction with multi-select: at
a minimum, your users would have to hold down the shift or ctrl key while
they're trying to type the search letters.

What about something similar to the paired list boxes you often see (you
know the ones that have arrows between them allow you to move the currently
selected item(s) from one list to the other, or move all items from one list
to the other)? You could have a combo box on the left, and a list box on the
right, both with the identical RowSource. Use the AutoExpand in the combo
box to select an item, then hit the button to have that item selected in the
list box (or you could use the AfterUpdate event of the combo box, rather
than requiring the user to click on a button)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JustAnotherGeek said:
I wouldn't characterize this as reinventing the wheel. As far as I
know, combo boxes do not support having multiple items selected at one
time (a requirement for the application), which is why the listbox is
being used instead of the combo box. I'm just looking for a way to
have a single control that works a little like both, that's all.

The application that I'm modifying is very stable and has been in
production for over ten years. Until recently, the number of items
(and the distribution of the first character in each) in my listbox was
such that the canned (single-character autoexpand) functionality of the
listbox was acceptable. Recently, the number of items in the listbox
has increased dramatically, and in some cases over 100 items start with
the same letter. This has made the existing built-in functionality
unacceptable to my users.

If there is no satisfactory solution to my problem, then the UI for my
application will probably have to change signficantly, which is
something I'm trying to avoid for obvious reaons.

I was just hoping somebody else had found themselves in this situation
before, and could help me out so that I don't have to reinvent
anything.


Ken is exactly right, why waste time re-inventing the wheel?
Combo boxes have the behavior that you seek already built-in (AutoExpand
property). Can you use a combo box for your purposes?

I have not done any "playing around" with making listboxes behave the
way
you want, sorry, so I don't have an "off-the-shelf" solution.

You might be able to use a textbox / listbox combination to let the user
type into a textbox the letters desired, then click button to fill the
listbox with the matching records.
I'm attempting to extend one of the features of a listbox in Access.

[quoted text clipped - 21 lines]
And my apologies in advance if this issue has been discussed already.
I
looked but didn't find anything that looked like this.
 

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