Supressing and error message

  • Thread starter Thread starter D B Lawson
  • Start date Start date
D

D B Lawson

Guest
I have a combo box that I'm trying to trap an error in. If the user selects an item from the box and then deletes it (possible!) and then tries to move off the field I get error message No 3162 "You are trying to assign the null value to a variable that is not a varient data type". All I want to do is replace that message with something more user friendly like DON'T DO THAT. Can't seem to suppress the message. Any ideas?

[This message has been edited by D B Lawson (edited 01-21-2001).]
 
When you create a Subprocedure or a function what you want to do is trap errors if any would result as in your case... Here is how to do it generically...

Private Sub AnySubOrFunction()
On Error Goto ErrorHandling

write some code
.
.
.

Exit_AnySubOrFunction:
Exit Sub

ErrorHandling:
if (err.number = 3126)
msgbox "Don't Do That",,"Warning"
else
msgbox err.description,,"Error: " & err.number
end if

resume Exit_AnySubOrFunction

Exit Sub

tc3of4
 

Users who are viewing this thread

Back
Top Bottom