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
Microsoft ExcelMicrosoft ApplicationsMicrosoft Access

Avatar of undefined
Last Comment
PeterBaileyUk

8/22/2022 - Mon
SOLUTION
Scott McDaniel (EE MVE )

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Jeffrey Coachman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
PeterBaileyUk

ASKER
As the queries were append queries I had to use the runsql command but your suggestions got me there thanks
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23