A
Antney
Hi,
I've figured out how to print Access reports to PDF but now that I've
printed them, I want, in VBA code, to figure out how I can get the VBA code
to automatically print each reports name, instead of me having to type it in
once the 'File Name' dialog box pops up and then send it automatically to a
specifed folder instead of me again, having to specify a path. Can anyone
help? Thanks!
BTW, in my 'qrySchools', which links the school id with the
'rptStudentDataSheet_0708' school id, I do have the school name. That's the
file name I want to use for each respective report.
Here is my code:
Option Compare Database
Option Explicit
Private Sub cmdPrintReports_Click()
On Error GoTo Err_cmdPrintReports_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport "rptStudentDataSheet_0708",
View:=acViewNormal, _
WhereCondition:="School = " & rs("School")
rs.MoveNext
Loop
End With
Exit_cmdPrintReports_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
Err_cmdPrintReports_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdPrintReports_Click
End Sub
I've figured out how to print Access reports to PDF but now that I've
printed them, I want, in VBA code, to figure out how I can get the VBA code
to automatically print each reports name, instead of me having to type it in
once the 'File Name' dialog box pops up and then send it automatically to a
specifed folder instead of me again, having to specify a path. Can anyone
help? Thanks!
BTW, in my 'qrySchools', which links the school id with the
'rptStudentDataSheet_0708' school id, I do have the school name. That's the
file name I want to use for each respective report.
Here is my code:
Option Compare Database
Option Explicit
Private Sub cmdPrintReports_Click()
On Error GoTo Err_cmdPrintReports_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport "rptStudentDataSheet_0708",
View:=acViewNormal, _
WhereCondition:="School = " & rs("School")
rs.MoveNext
Loop
End With
Exit_cmdPrintReports_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
Err_cmdPrintReports_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdPrintReports_Click
End Sub