Stop Dialogue Boxes

  • Thread starter Thread starter M Shannon
  • Start date Start date
M

M Shannon

I have a macro that first updates one table. Then it
deletes data in another and then adds data back to the
table.

When I run the macro I get the dialogue boxes saying, "Are
you sure you want to update 520 records?" or "Do you want
to delete the data in table so and so"!!

Is there a way I can get those boxes to stop being
displayed whilst the macro is running?

Many thanks
 
Add a SetWarnings action at the beginning of your macro, with argument
False.
Add another SetWarnings action at the end with argument True to restore the
previous status.
Note that if your macro halts in the middle before the last action is
executed, Access will no longer request confirmations for actions in that
session. One workaround is to have a separate macro with kust one action
SetWarnings False and run it manually whenever the macro halts, before you
do anything else.

HTH,
Nikos
 
It is not necessary to set the warnings back to true in a
macro. At the end of a macro the are set back to true
automatically.

Jim
 
Ah, but this is a bad programming habit.

If the macro ever gets converted to code you're in trouble.

When using the SetWarnings method of DoCmd in code, the warnings are *not*
atomically turned back on at the end of a procedure.

Turning them back on in a macro is just a good programming habit.

And you won't end up in trouble if/when the macro is converted to code.

My $.02 worth.

Sco
 
Guys,

You are both right, I suppose it all depends on where you're standing...
Actually I gave up on macros when I discovered VBA, so this is where I come
from.
Nikos
 
Well, here's my $.02 worth... Converting macros to code is not a good
programming habit. The conversion produces code which is always ugly
and often inefficient, and in the case of complex macros, it just can't
handle it anyway. If you want a macro, build a macro. If you want VBA
procedure, write code. And if you're going to use macros, use macro
rules, which means not bothering with SetWarnings/Yes.
 
Ah, in a perfect world where either you or I had trained them properly, I'd
agree with you.

unfortunately, I get too many students in my classes that were not properly
trained. There are many an instructor working for a nationally known (and to
remain unnamed) training company that don't know any more about Access than
what they are reading out of their training manuals.

The problem? Their training manuals are written by clueless people that make
the convert macro to code feature (and other things like the field lookup
feature,) sound like a "cure all" to all of your problems.

Even one of the other instructors at a training center I teach at doesn't
use naming conventions. And he even uses spaces in names. :-( Arrg.
Unfortunately, I am just one of many instructors there and I can't do
anything but straighten out the students later if they're lucky enough to be
in one of my classes after his.

Steve, if only you and I could train everyone first, there would be no need
for any of these groups...

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #17 of 19: 1 billion billion picolos = 1 gigolo
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Back
Top