Combobox... need an event similar to 'Not in List'


Posted by Kevin on August 02, 2001 6:35 AM

I need to have a 'Not in List' event the gets tricked after the user has entered a value into a combobox. I have the behaviour MatchRequired property set to True but when a user enters a value that is not in the list and press the Tab key, Excel returns 'Invalid property Value', not very user friendly.

Thanks in advance
regards
KM

KM



Posted by Cory on August 02, 2001 8:35 AM

Have you tried using an error trap that'll skip the "invalid poroperty" error? If not, try this:

Private Sub YourSub()
On Error GoTo errorname
(your code here...)
Exit Sub
errorname: msgbox ("Sorry, that's not valid. Try again...", vbokonly, "Invalid Choice")
Exit Sub
End Sub

You can change "errorname" to whatever you want to call the code that runs in event of an error. The keys here are the Exit Subs. If you don't have one BEFORE errorname and at the END of the error code, the error code will run whether there's an error or not...

Cory