View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
michelle michelle is offline
external usenet poster
 
Posts: 310
Default Access doesn't always close (Excel VBA) & passing parameters

Joel,

I had it as a function because originally I was trying to run the code by
calling an Access macro in Excel, and I thought the code had to be set up as
a function in order to use the line RunCode LoopReport in a macro. Perhaps I
was misinformed on this? Since I now know how to run a function or sub
directly using A.Run instead of A.DoCmd.RunMacro I can try your suggestion.
Thanks. Will let you know how it goes.

--
Cheers,
Michelle
"Anyone who says he can see through women is missing a lot." Groucho Marx


"Joel" wrote:

Why do you have LoopReport as a function when it is not returning any
variables. Why not make it a Sub. I believe the crashing is occuring
because you have a stack error. When you declare the routine a function it
is expecting something to be put on the stack and something to be taken of
the stack. You are calling LoopReport from excel like a Sub which isn't
putting anything on the stack. Then Access is leaving a space on the stack
for a return variable where excel didn't make room for the return variable on
the stack. This create a stack mis-match and the cause of the crash.