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

You have to modify the access macro or make a new macro in access that will
run either:

1) Using prompt for inputs
2) Take input from input parameters.

You need to post the Access macro.

"Michelle" wrote:

Hello all!

I'm using Access 2003 and Excel 2000

(1) I'm trying to run an Access macro from Excel. The code I have works,
but Access doesn't always quit. Sometimes there's no problem. Other times I
can see the macro is done, but Access doesn't close. I have to click on
Excel which gives me an error message which i click "OK", and then closes
Access and everything runs as it should. This is the code that I currently
have.

Dim A As Access.Application

Set A = New Access.Application
A.Visible = True
A.OpenCurrentDatabase "G:\PC Reports New\PC Report.mdb"
A.DoCmd.RunMacro "Multiple Accounts Report"
A.CloseCurrentDatabase
A.Quit
Set A = Nothing
' more Excel VBA code that works properly

(2) On a related note, I've been scouring around looking to see if there's
any way to pass in parameters directly into the Access module. I have found
nothing useful. Currently Access starts from Excel and runs the macro which
only consists of the line RunCode LoopReport. Once LoopReport starts the
user has to input parameters that are then used for a make table query. It
would make my life easier if I could have the user input the parameters in
Excel and then pass them into Access. Something along the lines of
A.DoCmd.RunModule "LoopReport(x,y)"
to replace the line
A.DoCmd.RunMacro "Multiple Accounts Report"

LoopReport being the underlying module in the "Multiple Accounts Report"
macro and x,y being the parameters I want to pass from Excel to Access. It
appears there's no RunModule method though. Is there something else I can
use? Hopefully that all makes sense.

Any help would be much appreciated, particularly the first part. Thanks!

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