Macros Won't Run

connellg

New member
Local time
Today, 12:25
Joined
Mar 18, 2007
Messages
3
This is the VBA code executed from OnClick on a form's command button, to run 4 macros:

Private Sub Command160_Click()
DBEngine(0)(0).Execute "Append to Delivery List Table", dbFailOnError
DBEngine(0)(0).Execute "Print Work Order", dbFailOnError
DBEngine(0)(0).Execute "Print Final Inspection", dbFailOnError
DBEngine(0)(0).Execute "New Record", dbFailOnError
End Sub

An error message states "Compile Error", "Variable Not Defined"

Would appreciate your help in de-bugging this. Thanks.
 
I don't know that execute will run macros. Try:

DoCmd.RunMacro
 
Thanks for your response. The reason I wanted to use the Execute method instead of DoCmd was to avoid the interactive messages that result from running action macros.
 
use DoCmd to run a macro
and use SetWarnings No to turn off the warnings
run the DoCmd lines
then SetWarnings Yes to turn them back on.

If done in code it is

DoCmd.SetWarnings False
DoCmd.RunMacro xxx
DoCmd.RunMacro xx2
DoCmd.SetWarnings True

But you should put a DoCmd.SetWarnings True in an error handler when doing that otherwise you could end up without any warnings at all if anything fails in between.
 
I think Execute will only run SQL or saved queries. Look at SetWarnings in your macros.
 

Users who are viewing this thread

Back
Top Bottom