Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

run access append query from excel

I tried this (found on ee) but hoping to run a query called qryTotalCWcarsYearsBreakdown but it fails on a.docmd.runmacro "qryTotalCWcarsYearsBreakdown"

so question is can i run an append query in this way from within excel?
Public Function RunAccessMacro()
     
'    Application.ScreenUpdating = False
'
'    Set A = CreateObject("Access.Application")
'
'    strDB = "N:\data\SimpleStats2.mdb"
'
'    A.OpenCurrentDatabase strDB
'    A.Visible = False
'    A.DoCmd.RunMacro "QryTotalCWCarsYearsBreakdown"
'    A.Quit
'
'    Set A = Nothing
'    Application.ScreenUpdating = True
     
End Function
SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterBaileyUk
PeterBaileyUk

ASKER

It stalls by saying object doesnt support this property or method runtime error 438

amended as advised to
Public Function RunAccessMacro()
     
    Application.ScreenUpdating = False

    Set A = CreateObject("Access.Application")

    strDB = "N:\data\SimpleStats2.mdb"

    A.OpenCurrentDatabase strDB
    A.Visible = False
   
   
 A.DoCmd.RunQuery "QryDeleteCW" ' delete table entries
A.DoCmd.RunQuery "QryTotalCWCarsYearsBreakdown" 'append to table
 A.DoCmd.RunQuery "QryDeleteSMMT" ' delete table entries
A.DoCmd.RunQuery "QryTotalSMMTCarsYearsBreakdown"  'append to table
    A.Quit

    Set A = Nothing
    Application.ScreenUpdating = True
     
End Function
As the queries were append queries I had to use the runsql command but your suggestions got me there thanks