Extract the query in Excel

Chateauk

New member
Local time
Today, 05:24
Joined
Nov 20, 2023
Messages
7
I've created a button on a form that calls this procedure. How do I update the procedure to open the query in Excel xlsx instead of MS Access datasheet view?

Private Sub RunMonthlyReportBtn_Click()

DoCmd.OpenQuery "qryMonthlyReport", acViewNormal, acReadOnly


End Sub
 
Link Excel to Access query or export query to Excel.
Why involve Excel?
 
Link Excel to Access query or export query to Excel.
Why involve Excel?
My team wants the button to generate an excel spreadsheet instead of them copying and pasting in excel
 
Investigate using the transferspreadsheet function to transfer the query to excel. Then either open excel or link to it to see the result
 
Opening a query this way is extremely dangerous if the query produces an updateable recordset. You have no way to prevent users from changing or deleting large numbers of records and there is no recovery from this.

Exporting to Excel makes sense if the user wants to use the data for other reporting but having the Access app open the spreadsheet is rare. If the user wants to just view the data, a better solution would have been a form based on the query. If the user wants to update the spreadsheet or format it as a report, etc, then you have to automate Excel to open the workbook and now the user is out of your application's control so hopefully, he is not expecting any changes in the data to be reflected in the access application.
 
Opening a query this way is extremely dangerous if the query produces an updateable recordset. You have no way to prevent users from changing or deleting large numbers of records and there is no recovery from this.

Exporting to Excel makes sense if the user wants to use the data for other reporting but having the Access app open the spreadsheet is rare. If the user wants to just view the data, a better solution would have been a form based on the query. If the user wants to update the spreadsheet or format it as a report, etc, then you have to automate Excel to open the workbook and now the user is out of your application's control so hopefully, he is not expecting any changes in the data to be reflected in the access application.
I do agree with your approach. Thank you
 

Users who are viewing this thread

Back
Top Bottom