I have the following code :
I am trying to create an excel worksheet that creates a tab for each "Branch". It works, except it prompts for me to put in the branch, instead of simply running through the loop.
Any ideas?
Code:
Private Sub ProbReport()
Dim dbs As Database
Dim rst As Recordset
Dim SQLProb As String
Dim strBranch As String
Dim strReportName As String
strReportName = "zProbReport"
DoCmd.SetWarnings False
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select * from zTempProb_BranchList")
With rst
.MoveFirst
Do While Not rst.EOF
SQLProb = "Select * into " & strReportName & _
" From ZTempProbXls " & _
"Where Branch = " & rst!Branch
DoCmd.RunSQL (SQLProb)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, strReportName, "C:\ams\LCLSProbs.xls", True, rst!Branch
rst.MoveNext
Loop
End With
DoCmd.SetWarnings True
End Sub
Any ideas?
Comment