A
Antney
Hi,
I'm trying to run this code and it ran fine the first two times, now I keep
getting an error message reading that my report does not exist, is not open
or is misspelled.
I keep looking over my code and I can't find the problem.
Can anyone help me out?
It would be greatly appreciated as I'm almost done with this project.
Thanks!!!
Here's my code:
Option Compare Database
Option Explicit
Private Sub cmdReportToPDF_Click()
On Error GoTo Err_cmdReportToPDF_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strReport As String
Dim strDocName As String
Dim blRet As Boolean
Dim strSQLBase As String
Dim strDocFolder As String
Dim strFilter As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblStudentDataSheet_0708", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"
strDocFolder = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\"
Do Until rs.EOF
strDocName = strDocFolder & rs!SiteName & ".pdf"
strFilter = "School=" & rs!School
DoCmd.OpenReport strReport, acViewNormal, , strFilter, acHidden
If Reports(strReport).HasData Then
Call ConvertReportToPDF(strReport, vbNullString, strDocName, , , 150)
End If
DoCmd.Close acReport, strReport
rs.MoveNext
Loop
rs.Close
Exit_cmdReportToPDF_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
Err_cmdReportToPDF_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdReportToPDF_Click
End Sub
I'm trying to run this code and it ran fine the first two times, now I keep
getting an error message reading that my report does not exist, is not open
or is misspelled.
I keep looking over my code and I can't find the problem.
Can anyone help me out?
It would be greatly appreciated as I'm almost done with this project.
Thanks!!!
Here's my code:
Option Compare Database
Option Explicit
Private Sub cmdReportToPDF_Click()
On Error GoTo Err_cmdReportToPDF_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strReport As String
Dim strDocName As String
Dim blRet As Boolean
Dim strSQLBase As String
Dim strDocFolder As String
Dim strFilter As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblStudentDataSheet_0708", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"
strDocFolder = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\"
Do Until rs.EOF
strDocName = strDocFolder & rs!SiteName & ".pdf"
strFilter = "School=" & rs!School
DoCmd.OpenReport strReport, acViewNormal, , strFilter, acHidden
If Reports(strReport).HasData Then
Call ConvertReportToPDF(strReport, vbNullString, strDocName, , , 150)
End If
DoCmd.Close acReport, strReport
rs.MoveNext
Loop
rs.Close
Exit_cmdReportToPDF_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
Err_cmdReportToPDF_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdReportToPDF_Click
End Sub