NotInList highlighting

  • Thread starter Thread starter Design by Sue
  • Start date Start date
D

Design by Sue

I have a combo box that is set to LimitToList. I coded On Not In List
property to beep to tell user the input was incorrect. I have found code
that will remove the incorrect entry but instead I would like the incorrect
entry to be selected so the user can type over it without using the mouse to
highlight it. How can this be done?

FYI the code Ihave ont the On Not In List property is:

DoCmd.Beep
Response = acDataErrContinue

Thanks
Sue
 
Design said:
I have a combo box that is set to LimitToList. I coded On Not In List
property to beep to tell user the input was incorrect. I have found code
that will remove the incorrect entry but instead I would like the incorrect
entry to be selected so the user can type over it without using the mouse to
highlight it. How can this be done?

FYI the code Ihave ont the On Not In List property is:

DoCmd.Beep
Response = acDataErrContinue

If you don't remove the invalid entry, you should get
another error.

Since you don't seem to have anything you want to
manipulate, I suggest that you set LimitToList to No and use
the BeforeUpdate event to check for an incorrect entry. I
think it would be like this air code:

If Me.thecombo.ListIndex = -1 Then
Beep
Camcel = True
End If
 
Thank you but that simply beeps if there is an errorwhen you click on the
button that adds the info to a list box I have on the page. The way I have it
is better because when you click the button you get the beep and the drop
down of the correct numbers to select from.

What I would REALLY like is something that checked the number against the
list as you typed and tell you as you type that there are no matching
numbers. The Part Numbers are five digits - a suffix of up to three digits
(ie 12345-1 or perhaps 12345-203) So if someone typed in 13 and there
were no part numbers that started with 13 the user would hear a beep. Like
wise if they entered 1236 the beep would be heard on the typing of 6 if there
were no numbers starting with 1236.
 
Thank you but that simply beeps if there is an errorwhen you click on the
button that adds the info to a list box I have on the page. The way I have it
is better because when you click the button you get the beep and the drop
down of the correct numbers to select from.

What I would REALLY like is something that checked the number against the
list as you typed and tell you as you type that there are no matching
numbers. The Part Numbers are five digits - a suffix of up to three digits
(ie 12345-1 or perhaps 12345-203) So if someone typed in 13 and there
were no part numbers that started with 13 the user would hear a beep. Like
wise if they entered 1236 the beep would be heard on the typing of 6 if there
were no numbers starting with 1236.

Marshall Barton said:
Design by Sue wrote:
If you don't remove the invalid entry, you should get
another error.
Since you don't seem to have anything you want to
manipulate, I suggest that you set LimitToList to No and use
the BeforeUpdate event to check for an incorrect entry. I
think it would be like this air code:
If Me.thecombo.ListIndex = -1 Then
Beep
Camcel = True
End If

I see where you're heading, and it smacks of a bit of KeyPress event
handling and a potentially painful bit of coding. I'm thinking that a
textbox above a listbox control might be the:

(a) Easiest thing to code so the entry can scroll the listbox and
alert the user in the way you describe and
(b) Provide a visually more intuitive interface.

The textbox-listbox combo I describe is used quite often in fontname
matches algorithms that do something similar.

My two cents (which are unfortunately usually worth about 2 cents),
James
 
I agree with Minton that doing this in a combo box would be
a mess that you would not be happy with. The idea of using
a text box along with a list box is a resonable alternative
where a combo box's automatice mechanisms wouldn't get in
the way.
 
James and Marsh, Thanks for the suggestion. Can you please give me some help
on doing this?

Thanks
Sue

Marshall Barton said:
I agree with Minton that doing this in a combo box would be
a mess that you would not be happy with. The idea of using
a text box along with a list box is a resonable alternative
where a combo box's automatice mechanisms wouldn't get in
the way.
--
Marsh
MVP [MS Access]

Thank you but that simply beeps if there is an errorwhen you click on the
button that adds the info to a list box I have on the page. The way I have it
is better because when you click the button you get the beep and the drop
down of the correct numbers to select from.

What I would REALLY like is something that checked the number against the
list as you typed and tell you as you type that there are no matching
numbers. The Part Numbers are five digits - a suffix of up to three digits
(ie 12345-1 or perhaps 12345-203) So if someone typed in 13 and there
were no part numbers that started with 13 the user would hear a beep. Like
wise if they entered 1236 the beep would be heard on the typing of 6 if there
were no numbers starting with 1236.
 
This is not a simple thing, especially if you are not
familiar with the concepts. First, I am afraid that I may
lead you down a strange lane because I always use a
continuous subform instead of a list box. While this
approach has several advantages, it is defintely not in the
mainstream. Given all that, I am reluctant to suggest such
an approach and recommend that you just live with the
original combo box without all this additional complexity.

If you feel that there is a serious need to proceed and are
willing to do the necessary homework to understand it, then
here's the general idea (with the caveat that I don't have
the time to set up a complete simulation of your arrangement
to test so it's just air code).

Use a text box's Change event to check if the Text property
exists in the subform's record source. If it is not, then
beep and throw away the last character. If it is, then
navigate to the first matching record:

With Me.thesubform.Form.RecordsetClone
.FindFirst "[Part Number] Like '" & Me.thetextbox.Text &
"*' "
If .NoMatch Then
Beep
Me.thetextbox.Text = Left(Me.thetextbox.Text, _
Len(Me.thetextbox.Text) - 1)
Else
Me.thesubform.Form.Bookmark = .Bookmark
End If
End With
 
Thank you for your response - I am going to give your reply to someone who
know database programming better than I and let him work on it. Will let you
know if we work it out!

Sue

Marshall Barton said:
This is not a simple thing, especially if you are not
familiar with the concepts. First, I am afraid that I may
lead you down a strange lane because I always use a
continuous subform instead of a list box. While this
approach has several advantages, it is defintely not in the
mainstream. Given all that, I am reluctant to suggest such
an approach and recommend that you just live with the
original combo box without all this additional complexity.

If you feel that there is a serious need to proceed and are
willing to do the necessary homework to understand it, then
here's the general idea (with the caveat that I don't have
the time to set up a complete simulation of your arrangement
to test so it's just air code).

Use a text box's Change event to check if the Text property
exists in the subform's record source. If it is not, then
beep and throw away the last character. If it is, then
navigate to the first matching record:

With Me.thesubform.Form.RecordsetClone
.FindFirst "[Part Number] Like '" & Me.thetextbox.Text &
"*' "
If .NoMatch Then
Beep
Me.thetextbox.Text = Left(Me.thetextbox.Text, _
Len(Me.thetextbox.Text) - 1)
Else
Me.thesubform.Form.Bookmark = .Bookmark
End If
End With
--
Marsh
MVP [MS Access]

James and Marsh, Thanks for the suggestion. Can you please give me some help
 
Thank you for your response - I am going to give your reply to someone who
know database programming better than I and let him work on it. Will let you
know if we work it out!

Sue

Marshall Barton said:
This is not a simple thing, especially if you are not
familiar with the concepts. First, I am afraid that I may
lead you down a strange lane because I always use a
continuous subform instead of a list box. While this
approach has several advantages, it is defintely not in the
mainstream. Given all that, I am reluctant to suggest such
an approach and recommend that you just live with the
original combo box without all this additional complexity.
If you feel that there is a serious need to proceed and are
willing to do the necessary homework to understand it, then
here's the general idea (with the caveat that I don't have
the time to set up a complete simulation of your arrangement
to test so it's just air code).
Use a text box's Change event to check if the Text property
exists in the subform's record source. If it is not, then
beep and throw away the last character. If it is, then
navigate to the first matching record:
With Me.thesubform.Form.RecordsetClone
.FindFirst "[Part Number] Like '" & Me.thetextbox.Text &
"*' "
If .NoMatch Then
Beep
Me.thetextbox.Text = Left(Me.thetextbox.Text, _
Len(Me.thetextbox.Text) - 1)
Else
Me.thesubform.Form.Bookmark = .Bookmark
End If
End With

Sue,

Try this example:

1. Create a listbox querying some table for some values and call it
List2.
2. Create a textbox above called Text0.
3. Paste this code into the Text0 change event:

Private Sub Text0_Change()

Dim i As Integer, sMatch As String, j As Integer

If Text0.Text = "" Then Exit Sub

For j = 1 To Len(Text0.Text)
sMatch = Left(Text0.Text, j)

For i = 0 To List2.ListCount - 1
If UCase(Left(List2.Column(0, i), j)) = UCase(sMatch)
Then
List2.Selected(i) = True
Else
List2.Selected(i) = False
End If
Next i
Next j

End Sub

..... I'm not claiming the code is pretty or efficient but it shows how
a textbox could drive the matching in the listbox.

Hope this helps,
James
 
Back
Top