View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MARK MARK is offline
external usenet poster
 
Posts: 1
Default 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