on error (trapping error) 
Author Message
 on error (trapping error)

Private Sub DisconnectDB()
On Error GoTo ErrorHandler
    recDb.Close
    connDb.Close
ErrorHandler:
    DatabaseError connDb.errors, "disconnectDb"
End Sub 'of DisconnectDB

the code above is ok but the code below is not, becos of i
"set the connDb to Nothing", why ? i tought that ErrorHandler
part would only be execute when there is a runtime error, but
when i trace/debug the code below...it does step through
the whole lines of code ie goes into my DatabaseError routine
any sugestion on doing error handler???

Private Sub DisconnectDB()
On Error GoTo ErrorHandler
    recDb.Close
    connDb.Close
    Set connDb = Nothing
ErrorHandler:
    DatabaseError connDb.errors, "disconnectDb"
End Sub 'of DisconnectDB

thanks
widjajaf

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 on error (trapping error)
Hi,

You need to make sure your errorhandler is not handled if there is no error,
insert an exit sub command in your routine, for example.

Private Sub DisconnectDB()

    On Error GoTo ErrorHandler
     recDb.Close
     connDb.Close
'make sure the error handler is not handled
exit sub
ErrorHandler:
     DatabaseError connDb.errors, "disconnectDb"
End Sub 'of DisconnectDB

--
Cees Harlaar
verander HL in NL om e-mail te sturen
change HL in NL te send e-mail.



Quote:
> Private Sub DisconnectDB()
> On Error GoTo ErrorHandler
>     recDb.Close
>     connDb.Close
> ErrorHandler:
>     DatabaseError connDb.errors, "disconnectDb"
> End Sub 'of DisconnectDB

> the code above is ok but the code below is not, becos of i
> "set the connDb to Nothing", why ? i tought that ErrorHandler
> part would only be execute when there is a runtime error, but
> when i trace/debug the code below...it does step through
> the whole lines of code ie goes into my DatabaseError routine
> any sugestion on doing error handler???

> Private Sub DisconnectDB()
> On Error GoTo ErrorHandler
>     recDb.Close
>     connDb.Close
>     Set connDb = Nothing
> ErrorHandler:
>     DatabaseError connDb.errors, "disconnectDb"
> End Sub 'of DisconnectDB

> thanks
> widjajaf

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 on error (trapping error)
Hi,

You need to make sure your errorhandler is not handled if there is no error,
insert an exit sub command in your routine, for example.

Private Sub DisconnectDB()

    On Error GoTo ErrorHandler
     recDb.Close
     connDb.Close
'make sure the error handler is not handled
exit sub
ErrorHandler:
     DatabaseError connDb.errors, "disconnectDb"
End Sub 'of DisconnectDB

--
Cees Harlaar
verander HL in NL om e-mail te sturen
change HL in NL te send e-mail.



Quote:
> Private Sub DisconnectDB()
> On Error GoTo ErrorHandler
>     recDb.Close
>     connDb.Close
> ErrorHandler:
>     DatabaseError connDb.errors, "disconnectDb"
> End Sub 'of DisconnectDB

> the code above is ok but the code below is not, becos of i
> "set the connDb to Nothing", why ? i tought that ErrorHandler
> part would only be execute when there is a runtime error, but
> when i trace/debug the code below...it does step through
> the whole lines of code ie goes into my DatabaseError routine
> any sugestion on doing error handler???

> Private Sub DisconnectDB()
> On Error GoTo ErrorHandler
>     recDb.Close
>     connDb.Close
>     Set connDb = Nothing
> ErrorHandler:
>     DatabaseError connDb.errors, "disconnectDb"
> End Sub 'of DisconnectDB

> thanks
> widjajaf

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trapping file sharing errors w/o ON ERROR?

2. DAO Error Trapping & Most Common Errors

3. Deadlock errors & vb error trapping

4. Custom 500 error page - trapping the error text?

5. Breaks on error even when error trapping set to break on unhandled

6. No Error or ERL number returned in error trap

7. On Error doesn't trap error!

8. ado errors not trapped by vb error object???

9. onerror trap doesn't trap error!

10. Compile error: Automation error, Error 32811: Unexpected error

11. Error 440 : Execution Error. How to trap Oracle error

12. Trapping Warning Messages, NOT Error Messages

 

 
Powered by phpBB® Forum Software