A
Antney
Hi,
How do I call 'Call ConvertReportToPDF'? Everytime I run this code, I get
the 'Sub or Function not defined.
Also, will this take care of the reports naming? When I comment out the
'Call ConvertReportToPDF' and run the code, it runs ok but my reports still
do not get named correctly, I have to manually type them in. The 'SiteName',
in my code, is in the query and table that I am using so I can't figure out
why they're not automatically being named.
Thank you!
Here's 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
Dim strReport As String
Dim strDocName As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"
With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport strReport, acViewNormal, , "School = " &
rs("School")
Reports(strReport).Visible = False
strDocName = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\ " & !SiteName & ".pdf"
Call ConvertReportToPDF(strReport, , strDocName, False, False)
DoCmd.Close acReport, strReport
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
How do I call 'Call ConvertReportToPDF'? Everytime I run this code, I get
the 'Sub or Function not defined.
Also, will this take care of the reports naming? When I comment out the
'Call ConvertReportToPDF' and run the code, it runs ok but my reports still
do not get named correctly, I have to manually type them in. The 'SiteName',
in my code, is in the query and table that I am using so I can't figure out
why they're not automatically being named.
Thank you!
Here's 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
Dim strReport As String
Dim strDocName As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"
With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport strReport, acViewNormal, , "School = " &
rs("School")
Reports(strReport).Visible = False
strDocName = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\ " & !SiteName & ".pdf"
Call ConvertReportToPDF(strReport, , strDocName, False, False)
DoCmd.Close acReport, strReport
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