Problem with error handling

der_roedie

New Member
Joined
Dec 16, 2009
Messages
29
Hello,

I've created an application that connects to a database and then retrieves records from there.
This data is then send to another system that contains data for these records.
Sometimes it can happen that for a record no data exists in the second system. This raises an error in my program, so i've added small errorhandlers to coop with this problem.

BUT: the first occasion this happens, the error get handled by the errorhandler and I continue my program withe the next record. But if that records also has no data then the errorhandler does not work :confused:

This is the code for the error handler:

Code:
If Err.Number = -2147220469 Then
    Err.Clear
    rst.MoveNext
    GoTo pointnotexist
End If

The number is the same for the second error so it should work i guess. I've added Err.Clear to reset the error before continuing but that didn't work either.

Any help and tips would be appreciated.
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
Would be better to see all of the code, but ry this

Code:
If Err.Number = -2147220469 Then
    Err.Clear
    rst.MoveNext
    Resume pointnotexist
End If
 

der_roedie

New Member
Joined
Dec 16, 2009
Messages
29
Thanks! This did the trick although I do not really understand the difference with the original code.
 

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
Resume keeps the error handler active.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,315
Members
414,053
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top