Userform combobox matchrequired = True; error with no selectio
On further testing, I'm stuck again. The combobox_click event is not
triggered when the user enters the control with the mouse, nor is it
triggered when the drop-down is selected; it only appears to occur when a
combobox item is selected.
My idea of putting a clear control over the combobox didn't work- I used a
clear label, and I can still select the combobox right through it.
When trying to replicate the error, I found the following: clicking in and
out without any changes actually doesn't throw the error; but if the user
clicks in and types a character, then hits backspace, the user is unable to
leave the control until a selection is made, even though they have deleted
their entry- there must be some event that alerts Excel that some change has
been made, after which point the value must match.
I guess my only hope would be if I could reset that 'changed' flag, but I'd
also have to be able to intercept the error message and use that as the event
to reset the flag. I have no idea how to trap that particular error, much
less determine whether the current combobox entry is "blank", so I think I'll
just have to give users explicit instructions instead of error-proofing the
form.
Thank you,
Keith
"JLGWhiz" wrote:
It would be easier to offer a suggestion if the CombBox code wast posted.
However, one way to handle it is to create a handling loop where a message
box is generated when the selection is made and the ComboBox event is
triggered. As an example, if you are using the click event:
Private Sub ComboBox1_Click()
dblChk = MsgBox("Are you sure you want to select " & _
Me.ComboBox1.Value, vbYesNo + vbQuestion, _
"CONFIRM SELECTION")
If dblChk = vbNo Then
Me.ComboBox1.Value = -1
Exit Sub
Else
'Your current code here
End If
End Sub
The object is to reset the ComboBox to empty without triggering any other
event.
"ker_01" wrote in message
...
I have a userform that includes a combobox which is optional for the user,
but if they do use it, they have to select one of the three values
provided
(no creativity allowed).
This works fine if the user ignores the field, or if they make a
selection.
They can even click the combobox 'arrow' to see the values and then click
to
another part of the form without making a selection. They can tab through
controls including this one without any problem. All good.
However, a user may enter the field (mouseclick) thinking they might want
to
make a selection, then decide against it. In those cases, they should be
able
to click on another control, tab away, or click the submit or cancel
commandbuttons on the form without error.
However, the actual behavior is that once the combobox field is entered by
the cursor via a mouse click, a selection is required. Attempting to leave
the combobox without a selection results in the error "Microsoft Forms:
Invalid property value"
Is there a different way to set up the combobox that avoids this error? I
do
not want to offer the user a "blank" value, because after making a
selection
they are not allowed to remove it (they can change it to another of the
three
values, they just aren't allowed to blank it out again). I'd be happy if
there was a way to block the mouse from selecting (setfocus?) within the
combobox as long as they could still select the combobox downarrow and
select
a value from there.
Thank you,
Keith
.
|