StayAtHomeMom
Technical User
I am using VB within my Access database (behind a button on a form) to run a query; output the results to Excel; open up that Excel file; format the file, and close it using the code below:
DoCmd.OutputTo acQuery, "RPT_BR002_Report", acFormatXLS,"C:\Brady\RPT_BR002.xls", False, "", 0
Workbooks.Open "C:\Brady\RPT_BR002.xls"
‘formatting;saving and closing the file code goes here
What I want to do is run the above query and save it to Excel as before, but not close the file so I can add a new sheet, run a different query, saving the results TO THAT SAME FILE, just to a different worksheet.
I am not having success with this because I’m using the same command, DoCmd.OutputTo acQuery… using the same file name. VB doesn’t like that. It gives me a runtime error "2302", "Access can't save the output data to the file you have selected"
Any suggestions on this? Again, what I’m trying to do is “reuse” an existing file to run more queries, and saving the results to different (new) worksheets.
Thanks for all your help and expertise!
DoCmd.OutputTo acQuery, "RPT_BR002_Report", acFormatXLS,"C:\Brady\RPT_BR002.xls", False, "", 0
Workbooks.Open "C:\Brady\RPT_BR002.xls"
‘formatting;saving and closing the file code goes here
What I want to do is run the above query and save it to Excel as before, but not close the file so I can add a new sheet, run a different query, saving the results TO THAT SAME FILE, just to a different worksheet.
I am not having success with this because I’m using the same command, DoCmd.OutputTo acQuery… using the same file name. VB doesn’t like that. It gives me a runtime error "2302", "Access can't save the output data to the file you have selected"
Any suggestions on this? Again, what I’m trying to do is “reuse” an existing file to run more queries, and saving the results to different (new) worksheets.
Thanks for all your help and expertise!