Re: Is David Fenton right about error handling?



Tim Marshall wrote:
[snip]
> COnsider a command button whose only purpose is open a form. The form
> to be opened has a number of checks in its on open event. COnsider an
> editing form we *don't* want to open if there is no record selected on
> the continuous for or sub form data*** on the calling form. In the
> frmSetUpWeather form below, the on open event checks for a currently
> selected record (or indeed if there are any records in the calling
> form). If this condition fails, then a msgbox explains the problem
> and cancel = True.
>
> This will always generate a 2501 error from the calling procedure and
> I handle such as shown in the code below. However, this is a lot to
> write (though much of it is simply rote with me), so frequently what
> I do is knowing the only real error will be the 2501, I do this:
[snip]

What I did for this (and for reports) was create a wrapper function for
OpenForm and OpenReport that traps for and ignores error 2501 just as your
second example does. Now I just use that function instead of the normal
ones and I only had to write the "correct" code once instead of hundreds of
times.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.