Let user type and finish only Correct List for ComboBox (1 Viewer)

Bill Bisco

Custom User Title
Local time
Today, 12:47
Joined
Mar 27, 2009
Messages
92
Dear all,

I have searched the internet and found several helpful threads such as the following below:

If LimitToList is True, you can put code in the combo box's NotInList event.
You can display your own message should you want, or choose not to display
anything. In either case, set

Response = acDataErrContinue
Public Function InTheList(CheckList As ComboBox) As Boolean
'#############################################################
'## This takes the current text from the combo and compares ##
'## to each item in the list. If an item matched then the ##
'## function is set to True. Else set to False ##
'#############################################################

Dim x As Integer

If CheckList.ListCount > 0 Then

For x = 1 To CheckList.ListCount

If CheckList.Text = CheckList.List(x - 1) Then
InTheList = True
GoTo EndThisNow
Else
InTheList = False
End If

Next x
Else
InTheList = False
End If

EndThisNow:

End Function
However, none of them succinctly deal with the main issue I feel is important. I want the user to be able to type in a combo box an item in a predefined value list or click the down arrow and choose from the list, but should only be able to type characters which are present in the list itself, for example. If I had a list of the following words:

  1. Red Rose
  2. Ruby Rose
  3. Yellow Rose
If the user typed *R*, they would only proceed by being able to type and *e* or a *u* because those are the only characters followed by an R in the list, and so on and so forth.

Has anyone developed any code to do such a thing so far? Restrict the user's ability to only type what is already present on the list?

Any help is appreciated,
Bill
 

boblarson

Smeghead
Local time
Today, 10:47
Joined
Jan 12, 2001
Messages
32,059
Bill -

I think trying to keep anyone from typing anything at all that is not in the list is just going to take too many resources to do it and you will find that the response time is going to be horrible unless there will only be a very small number of choices.
 

Bill Bisco

Custom User Title
Local time
Today, 12:47
Joined
Mar 27, 2009
Messages
92
There should not be more than 6 choices in one case, in the others, there should not be more than 3 choices.

On a similar note, is there a way such that as a user is typing, they see below them several suggestions for words. For example if I had a list of the following:


  1. Grand Canyon
  2. Grand Mesa
  3. Grand House
  4. Grand Waterfall
  5. Old Faithful
If I typed in a G, I would see a list of G suggestions to mouseover and select?
 

boblarson

Smeghead
Local time
Today, 10:47
Joined
Jan 12, 2001
Messages
32,059
That is true and so my second method would be what you originally asked for.
 

Users who are viewing this thread

Top Bottom