Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro runs but kills caller

Status
Not open for further replies.

groleau

Programmer
Apr 12, 2006
110
US
Working access DB with code like:
Code:
  Function Func_All
     Call Sub1
     Call Sub2
     Call Sub3
  end function
This code is called by a Macro that says
Code:
Warnings Off
RunCode Func_All
Warnings On
Quit

Calling it from outside, using
Code:
MDB.OpenCurrentDatabase(Access_DB)
MDB.DoCmd.RunMacro("Mac_All")
worked fine.

But then, I had to replace Sub2 with an SQL script.
I tested running the script by itself and it worked.
So I created Func_A to call Sub1 and Func_B to call
Sub3. Made two copies of the macro, Mac_A and Mac_B
and changed the function names accordingly. Changed
the outside code to
Code:
MDB.OpenCurrentDatabase(Access_DB)
MDB.DoCmd.RunMacro("Mac_A")
SQL_Script(<filename>)
MDB.DoCmd.RunMacro("Mac_B")
At the second line I get an exception with the message
"The RunMacro action was canceled."

I removed the Quit (which I should have done first)
but got the same thing. I put a Stop at the beginning
of Sub1 and stepped through it. All statements ran the
same as always, but when I stepped "into" the end
statement, I got the same exception in the outside
routine.

???


--
Wes Groleau
 
UPDATE:
I restored an old copy of the database from
SourceSafe, and put the outside VB code back.

Same behavior: The macro does everything it's
supposed to do, but then the outside code
says "RunMacro action was canceled"

The same two pieces of code (VBA and VB.net)
worked together properly this morning.

--
Wes Groleau
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top