troubleshooting Question

Extract queries to Excel tabs

Avatar of CFMI
CFMIFlag for United States of America asked on
Microsoft Access
7 Comments1 Solution357 ViewsLast Modified:

I am trying to extract two queries into a workbook using a template but only the last query inserts into its tab. The first tab is blank, can you please help?

Do While Not rstTables.EOF
DoCmd.OpenQuery "QdelTblEmailPayTemp", acViewNormal, acEdit
     strSql = "INSERT INTO TblEmailPayTemp([Contact],[EmailAddress],[FirstName])" & _
     "SELECT TblEmailPayments.Contact, TblEmailPayments.EmailAddress, TblEmailPayments.FirstName FROM TblEmailPayments WHERE TblEmailPayments.Contact = " & Chr$(34) & rstTables.Contact & Chr$(34) & ";"

FileName = "S:\Finance\Accounting Operations\National Accounts\Databases\EmailedParplans\" & [rstTables].[Contact] & "MPP.xls"
FileNameR = "S:\Finance\Accounting Operations\National Accounts\Databases\EmailedParplans\" & [rstTables].[Contact] & "MPP.pdf"
DoCmd.RunSQL strSql
FileCopy "C:\MonthlyParplanDetail.xls", "C:\WINDOWS\MonthlyParplanDetail.xls"
DoCmd.OutputTo acOutputQuery, "ParPlanDetails", acFormatXLS, "C:\WINDOWS\MonthlyParplanDetail.xls.ParPlanDetails", False, ""
DoCmd.OutputTo acOutputQuery, "ParPlanSummary", acFormatXLS, "C:\WINDOWS\MonthlyParplanDetail.xls.ParPlanSummary", False, ""
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros