Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.sovam.com!news.mi.ras.ru!spln!extra.newsguy.com!newsp.newsguy.com!news7 From: a@b.com Newsgroups: comp.lang.basic.visual.misc Subject: Error handling problem Date: Tue, 07 Feb 2012 14:55:37 -0800 Organization: NewsGuy - Unlimited Usenet $19.95 Lines: 54 Message-ID: NNTP-Posting-Host: pfe9098d1085d36f0b63b94a36b3af2cc7db97abffb03db0d.newsdawg.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 4.2/32.1118 Xref: x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:742 In the following code the first time an error occurs in (code 2) the error handler goes to Err_Label2. But on the next loop iteration if an error occurs in block (code 2) neither of the error handlers are called. The error is thrown back to the caller that called MyFunction. It is as if on the second iteration the error handler "On Error Goto 0" is in effect. Can anyone reproduce and/or explain this behavior? Function MyFunction() Dim ErrNum On Error Goto Err_Label (code 1 - read recordset MyRs) MyRs.MoveFirst Do Until MyRs.EOF On Error Goto Err_Label2 (code 2) Err_Label2: ErrNum = Err.Number Err.Clear On Error Goto Err_Label If ErrNum <> 0 Then (do something) Else (do something else) End If MyRs.MoveNext Loop Exit_Label: (cleanup code) Exit Function Err_Label: (code) Resume Exit_Label End Function