Rather than using Error
I would suggest you to use Err
statement to get the error number and depending on it perform your action.
Update:
You need to write your condition If Str(Err) = "4294" Then
inside the error handler.
errorhandler:
If Str(Err) = "4294" Then
curdoc.Flag = " Invalid Short name"
curdoc.defaulterSLACount = CInt(defaultCount)
Call curdoc.Save(False, True)
Else
Or you could write code to handle error specifically for 4294
...
...
...
On Error 4294 goto AmbiguousError doc.send(True)
...
...
...
Exit sub
AmbiguousError:
Set namesdb= session.getdatabase(db.server, "names.nsf")
Set Persondoc= namesdb.getview("($Users)").getdocumentbykey(docmail.SendTo(0))
docMail.SendTo = Persondoc.fullname(0) & "@" & Persondoc.MailDomain(0)
Call docMail.Send(True)
Resume next
End sub
The above code snippet was taken from this TechNote.