Re: Error Handling Routine
- From: "Graham R Seach" <gseach@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 1 Apr 2005 17:36:44 +1000
Dave,
I just stumbled across this thread. I don't know who wrote that bit, but I
agree that it's pretty silly thing to do.
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
"dave h" <none@xxxxxxxx> wrote in message
news:eDS4hvgGFHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
>I didn't mean to sound like I was passing judgement on the experts -
>because
> I'm definitely an Access novice. And, the book is generally quite
> helpful.
> BTW, this one is written by some other folks Cardoza, Hennig, Seach &
> Stein - who also seem to be very competent. So, clearly I could be
> misintrepeting something about the context - but I'm having trouble seeing
> what that is. And this is not about beating an issue to death - I'm still
> wondering if I'm missing some important point as I try to develop a good
> error handling model that I can use over and over. If someone has some
> insight, the book again is WROX Access 2003 VBA Programmer's Reference and
> their final error handling model is on page 277. I have no doubt that I
> could be misunderstanding how the Err.number display yields a valid result
> when it comes shortly after the "On Error Resume Next". The only 2 lines
> of
> code between the two are:
> DoCmd.SetWarnings True
> DoCmd.Hourglass False
> Which they describe as cleanup items and should not restore a previously
> cleared error code. They mention that the "On Error Resume Next", which
> is
> the first line of "Error_Handler:" is used for "This overrides the normal
> error handling and forces the code to contineue even if an error is
> encountered".
>
> Any insight will be appreciated. Thanks, Dave H
>
> "PC Data***" <nospam@xxxxxxxxxxx> wrote in message
> news:r12Td.5102$Ba3.324@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> Sussman and Smith are too good to have done that!
>>
>> Reread your book slowly and carefully. Check the context of what they are
>> doing.
>>
>> --
>> PC Data***
>> Your Resource For Help With Access, Excel And Word Applications
>> resource@xxxxxxxxxxxxxxx
>> www.pcdata***.com
>>
>>
>> "dave h" <daveharney@xxxxxxxxx> wrote in message
>> news:#oWitybGFHA.3648@xxxxxxxxxxxxxxxxxxxxxxx
>> > Thanks Mark,
>> > Kind of annoying however, as I took that error handling routine from
>> > the
>> > WROX book Access 2003 VBA and they clearly use the On Error Resume Next
>> and
>> > then use a msgbox to display err.number and err.description. Sure glad
>> you
>> > guys are around. Dave H.
>> >
>> > "Mark" <no_email> wrote in message
>> > news:erl7VQbGFHA.3908@xxxxxxxxxxxxxxxxxxxxxxx
>> > > Get rid of the On Error Resume Next, or put it after the Msgbox; it's
>> > > clearing the error number before you get a chance to use it.
>> > >
>> > >
>> > > "dave h" <daveharney@xxxxxxxxx> wrote in message
>> > > news:OE1c4LbGFHA.3928@xxxxxxxxxxxxxxxxxxxxxxx
>> > > > Hi,
>> > > > In the code below, I created a small simulation of what is
>> > > > happening
>> in
>> > a
>> > > > larger context. Of course this is bad code, but I wanted to force
> an
>> > > > error
>> > > > to get at the error handling problem. If I run this code without
>> > > > my
>> > error
>> > > > handler (comment out the On Error Goto...) then Access returns a
>> message
>> > > > box
>> > > > for a runtime error of 91 and its description. With my error
> handling
>> > > > enabled, my message box returns an error of 0 and no description.
>> This
>> > is
>> > > > the same behavior I get in my actual project. What am I doing
> wrong?
>> > > > Thanks, Dave H.
>> > > >
>> > > > Private Sub btnTest1_Click()
>> > > > On Error GoTo Error_Handler
>> > > >
>> > > > Dim rst As Recordset 'force an error
>> > > > Forms("frmTest1").Controls("txtTest1") = rst.Fields("xx")
>> > > >
>> > > > Exit_Procedure:
>> > > > Exit Sub
>> > > > Error_Handler:
>> > > > On Error Resume Next
>> > > > MsgBox "error Number " & Err.Number & ", " & Err.Description,
>> > > > Buttons:=vbCritical
>> > > > Resume Exit_Procedure
>> > > > End Sub
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>
.
- Prev by Date: Re: Attempting to add reformatted data to a subform
- Next by Date: Prompt for text
- Previous by thread: run time error 3075.
- Next by thread: Prompt for text
- Index(es):