RE: GotoField in field Exiting event Martha Geppert 11.Jul.13 07:40 PM a Web browser Applications Development All ReleasesAll Platforms
Using "Goto" in your code is not a good practice if it can be avoided by writing better tests.
Your code as written will always execute the "leave" code because of the way you wrote your test and the lack of any code exiting the subroutine if it finds the document, so it appears to be doing the event multiple times in that case.
Try changing your code to execute if the lookup is unsuccessful and to bypass it and exit the subroutine if successful, i.e.:
Set lookupDoc = lookupView.GetDocumentByKey(empName,True)
If lookupDoc Is Nothing Then
Msgbox Cstr(doc.ReportTo(0)) + " not found in the Domino Directory.", 0 + 48, "Name Not Found"
I don't know if that will fix the problem, but it should help because you won't be returning the user to the field if the lookup is successful, so it shouldn't execute the Exiting code multiple times in that situation.