M
Michelle
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!
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!