Error collection

Posted on 2005-05-12
Last Modified: 2010-05-01

I use this code to connect to database Access and run some update query.

Dim db As Database
Dim qd As QueryDef
Set db = OpenDatabase(nomefile)

On top of code i use

on error resume next

to manage errors.

My problem is :

at end of code the number of error is one (errors.count)
there is only last error in err(0).description
but the errors are most...

if i comment last sql update, the error indicated is last not commented !

How i read all error ???

Question by:kaiou
    1 Comment
    LVL 19

    Accepted Solution

    The reason you get only 1 error (the last one) is because On Error Resume Next automatically does also Err.Clear. So, instead of using On Error Resume Next, use On Error Goto errHandling, as in:

    'on top of code
    On Error GoTo errHhandling

    'do you stuff

    Exit Sub

    'here you can count the errors, collect their numbers and descriptions, handle it, clear it, and resume or resume next when
    'you finish doing all the handling.
    End Sub


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now