Alert message suppression - how to?

PortalMelt

New member
Local time
Today, 15:28
Joined
Oct 8, 2002
Messages
7
I have a macro that runs 29 SQL commands against a table in my Db. The function of the macro works fine, but when I run it I get a confirmation alert for every one of the 29 SQL commands that requires me to confirm each one manually.

Is there a way to suppress these alerts so I don't have to interact with them.

Thanks,
Jeff
 
I found the answer.

For the record:

>Tools
>Options
>Edit/Find
>Confirm
-Deselect "Action queries"
-Click "OK"
 
Or you can convert the macro to code and add the following before and after the actions.

'add before your action code
DoCmd.SetWarnings False

'add after your action code but before End Sub
DoCmd.SetWarnings True

Autoeng
 
Thanks Autoeng,

I understand the command you gave.

Can you explain how to convert to code? And then where do you run it from, is it still a macro?

Thanks,
Jeff
 
It will no longer be a macro but instead will be an event procedure. If you haven't already created a command button on a form to initiate the macro, do so now. In your command button properties select the On Click and point it to the macro. Next select Tools - Macro - Convert Form's Macros to Visual Basic. Select both boxes that appear. This will convert your macro into code. The On Click line will now say [Event Procedure]. Click the ... beside the line and you will be taken to the VBA editor and will be in the On Click event for your button.

After Private Sub YourLabel_Click() add the following

DoCmd.SetWarnings False

On the line above the End Sub statement add the following

DoCmd.SetWarnings True

Now select the Compile button (looks like sheets of paper stacked on top of each other). Hoepfully you won't get any errors.

Now select the Save button. Exit the VBA editor.

Open your form in Form view and try out the button. It should run the reports without stopping now.

Autoeng
 
Here How you do it

I don't think you have to convert anything to code. . .blah blah blah. If I'm reading it right, all you need to do is:

Go into ythe design of your macro and insert a new line at the very top. Hit the drop down arrow, then select SetWarnings [make sure it says NO at the bottom (meaning the Warnings On = No)].

Then go to the last line and add another SetWarnings line and Make sure the Warnings On = yes. . . This insures that you only take the alerts off while the Module is running, otherwise your alerts will be turned off for everything.

Run it you should be golden. . .GL.
 
I've tried the setwarnings in a macro and it doesn't work for all warnings like the vb code does. Try it in the macro and if it works, great, if it doesn't, convert to code.

Auteong
 

Users who are viewing this thread

Back
Top Bottom