ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   One subroutine to run another (https://www.excelbanter.com/excel-programming/379869-one-subroutine-run-another.html)

MARK

One subroutine to run another
 
I have a process where I run a query and then send those results
directly to Excel.

I want to have the user click the button - run the query through one
subroutine and then after that sub is done run the subroutine that
transfers to Excel. Simply, all I'm looking for is the code that I
put in the first sub that executes the second sub at the right time.

Here are the subs

Private Sub OpenMonthlyReportForm_Click()
On Error GoTo Err_penMonthlyReportForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MonthlyReport Calendar"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_penMonthlyReportForm_Click:
Exit Sub

Err_penMonthlyReportForm_Click:
MsgBox Err.Description
Resume Exit_penMonthlyReportForm_Click

End Sub

Then to transfer this is the sub

Private Sub MonthlyReport_Click()
On Error GoTo Err_MonthlyReport_Click

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"sumquery", "C:\MonthlyReport.xls", True
Application.FollowHyperlink "C:\MonthlyReport.xls"

Exit_MonthlyReport_Click:
Exit Sub

Err_MonthlyReport_Click:
MsgBox Err.Description
Resume Exit_MonthlyReport_Click

End Sub



All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com