On Error Problem - Not catching second time

Hi,

The on error statement doesn’t catch the same error the second time. In the code below, the error handler doesn’t catch the error the second time, when a particular groupdoc is not found. See comments in <<<…>>>

Sub Initialize

On Error Goto ErrorTrap



Dim ss As New notessession

Dim sdate As New notesdatetime("08/18/95 01:36:22 PM")



'search for blank flag - if flag is blank then notification needs to be sent

Set db = ss.currentdatabase



searchstring = |form = "1035" & NotificationFlag = ""|



'get the first document in the collection that meets the criteria

Set doccoll = db.search(searchstring,sdate,0) 

Set doc = doccoll.getfirstdocument()

'Cycle through the collection and send notifications to the Notify Area Group and, if needed, the Notify Country Group

While Not doc Is Nothing		

	Dim groupdoc As NotesDocument

'Get the Notify DD doc that matches the request’s Affected Area

	Set notifyview = db.GetView("NotificationSetup")

	Set groupdoc = notifyview.GetDocumentByKey(area)

'Get the Notify DD doc’s Notify Area group & Notify Countries

	areaGroup = groupdoc.NotifyAreaGroup(0) <<< See Object variable not set, error message here the second time it loops, even though there is an error handler>>>

getnext:

	'go to next document		

	Set doc = doccoll.getnextdocument(doc)

Wend

Exit Sub

ErrorTrap:

'Process Error

Goto getnext	

End Sub

Subject: On Error Problem - Not catching second time

You should use “Resume getnext” instead of “Goto getnext”.

You’re not leaving the error trap with the Goto.