Link to home
Start Free TrialLog in
Avatar of stephenlecomptejr
stephenlecomptejrFlag for United States of America

asked on

Does err = 0 and err.Clear do the same thing? Which one clears the error from the stack?

Within Microsoft Access VBA, if I want to remove an error completely from memory do I use Err = 0 or Err.Clear?

ASKER CERTIFIED SOLUTION
Avatar of athomsfere
athomsfere
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

 Either will work.

Jim.
 I just tested this and either will work, but err.clear is better.  

  Doing:

  Err = 0

  Doesn't clear the error object (ie. the last error description still remains).  However it will work as you would think for in-line error handling. i.e.

  On Error Resume Next
  Err = 0
  ' Do something
  If Err<>0 then
    ' Error occured
  End If

Jim.
"  Doesn't clear the error object (ie. "
Then they are not the same.

"Use Clear to explicitly clear the Err object after an error has been handled, "

mx
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"so it's hard to say what Err = 0 actually does. "
Which is why I don't use it in this context.

Stephen ... if you want the ultimate error handler, then see this:

http://www.everythingaccess.com/vbwatchdog.htm

And lots of great info in this site ...

mx
Avatar of stephenlecomptejr

ASKER

Thanks for all the great replies!
I appreciate the comments.