could someone look at my code please and tell me what's wrong? tha

B

Blondie

Sub RunAccessMacro()

Dim appAcc As Access.Application

'Opens Access or gets reference to app already running

Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.OpenAccessProject
"P:\Analytic\Heather\Individual\IndividualTurnoverReport.mdb"

appAcc.DoCmd.RunMacro "Macro1: Get Data"
appAcc.DoCmd.RunMacro "Macro2: Create Report"

'Close Access
appAcc.Quit

'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing

End Sub
 
N

Norman Yuan

See comment inline.


Blondie said:
Sub RunAccessMacro()

Dim appAcc As Access.Application

'Opens Access or gets reference to app already running

Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.OpenAccessProject
"P:\Analytic\Heather\Individual\IndividualTurnoverReport.mdb"


Application.OpenAccessProject() is used for opening Access project file
(*.adp), not *.mdb.

You should use

appAcc.OpenCurrentDatabase
"P:\Analytic\Heather\Individual\IndividualTurnoverReport.mdb"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top