Suppress error message when macro runs

  • Thread starter Thread starter diannem
  • Start date Start date
D

diannem

I am not a very experienced ACCESS user and have Access
2002 in Office XP.

I have set up a group of macros that work but display
messages such as -- can't find file -- which is valid if
the file has been deleted.

It then requires me to click enter to continue and brings
up the FailMacro window where I have to click on HALT in
order to continue. I want to retain the macros, as is, to
essentially ensure that a file has always been deleted
before my group of macros is run but either suppressing
the error message or entering the needed response into my
group of macros so that they go on to the next step.

I tried Echo -- off, and SetWarning -- Warning -- off;
these did not supress the messages. My next thought is to
enter "OnError"... but I am not sure what I should enter
then and where in the Macro to put it.

Any thoughts or experience you might be willing to share
would be VERY much appreciated!!
Dianne
 
Macros will not handle errors the way you want. Using VBA code, you can
intercept errors and display your own messages.

You'll need to do your programs with VBA to get the desired result.
 
Thank you very much for your speeddy response, Ken.

I feared VBA might be the answer. Does this mean
replacing my macros et al with VBA or is it possible to
incorporate my macros into a VBA program?
Dianne
 
Hmmm... good question. I set up a test case that created an error in a macro
and then called the macro from VBA code.

What I found is that the error caused the macro to display its error "halt"
message window. Clicking OK then allowed the VBA code to display my message
from the code's error handler.

So I believe just calling your macros from VBA code (with error handling in
the code) will not solve your problem. You'll need to put the macro's
actions (at least the steps where the errors can occur) into VBA code.
 
Dianne,

Yes, you can still use the macros, within the VBA procedure. It will
look something like this...

If Len(Dir("C:\YourPath\YourFile") Then
Kill "C:\YourPath\YourFile"
End If
DoCmd.RunMacro "NameOfYourMacro"
 
-----Original Message-----
Hmmm... good question. I set up a test case that created an error in a macro
and then called the macro from VBA code.

What I found is that the error caused the macro to display its error "halt"
message window. Clicking OK then allowed the VBA code to display my message
from the code's error handler.

So I believe just calling your macros from VBA code (with error handling in
the code) will not solve your problem. You'll need to put the macro's
actions (at least the steps where the errors can occur) into VBA code.

--

Ken Snell
<MS ACCESS MVP>




.
 
Back
Top