J
JohnK
Hello, I have a query that has all the fields required in it. I then made a
report from that query and grouped it on a field "Processor". What I would
loke to do is run the report for each processor in the query and have it save
the file as an excel document with the name "REKICK_[the processor
field]_today's date.xls". I am trying to make it loop through and leave a
file for each processor that has data in the query. I am trying the code
below but it errors in the spot marked. I am new to loops and somewhat new
to vba.
My attempt:
Private Sub Command220_Click()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryRekicks")
With rst
If Not (.EOF And .BOF) Then
..MoveLast
..MoveFirst
Do
DoCmd.OpenReport "qryRekicks", acViewPreview, , "[Processor] = " &
..Fields![Processor]
--STOPS ON NEXT LINE--
DoCmd.OutputTo acOutputReport, "qryRekicks", acFormatXLS, "\\My Server Name
Goes Here\data\DailyReports\current\" & "REKICK_" & [Processor] &
Format(Date, "mmddyy") & ".xls", False
DoCmd.Close acOutputReport, "qryRekicks", False
..MoveNext
Loop Until .EOF
End If
..Close
End With
Set rst = Nothing
Set db = Nothing
End Sub
Thank you for your help.
John
report from that query and grouped it on a field "Processor". What I would
loke to do is run the report for each processor in the query and have it save
the file as an excel document with the name "REKICK_[the processor
field]_today's date.xls". I am trying to make it loop through and leave a
file for each processor that has data in the query. I am trying the code
below but it errors in the spot marked. I am new to loops and somewhat new
to vba.
My attempt:
Private Sub Command220_Click()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryRekicks")
With rst
If Not (.EOF And .BOF) Then
..MoveLast
..MoveFirst
Do
DoCmd.OpenReport "qryRekicks", acViewPreview, , "[Processor] = " &
..Fields![Processor]
--STOPS ON NEXT LINE--
DoCmd.OutputTo acOutputReport, "qryRekicks", acFormatXLS, "\\My Server Name
Goes Here\data\DailyReports\current\" & "REKICK_" & [Processor] &
Format(Date, "mmddyy") & ".xls", False
DoCmd.Close acOutputReport, "qryRekicks", False
..MoveNext
Loop Until .EOF
End If
..Close
End With
Set rst = Nothing
Set db = Nothing
End Sub
Thank you for your help.
John