Cannot Output Access Reports PDF Files

A

Antney

Hi,

I've been trying to use Lebans code for outputting Access reports to PDF
files but to no avail.

What I want to do is print 110 schools, with their respective names, to a
folder in My Folders. I want all of this done with just one click of the
print button. I also don't want to see the 'Save Dialog' box. I want all of
the reports to print, to .PDF and then go to a specified folder.

I've got half of it working, I think but it is still not outputting the
files, in PDF format to where I want them.

I've copied over Lebans two .dll files into the folder where my .db is and
I've copied over all the modules and classes into my .db. I still can't get
it to work.

Can anyone help? Please let me know if I need to explain in with more
clarity. Thanks! (I also posted this in forms coding, sorry for the dupe)

Here is my code:

Option Compare Database
Option Explicit

' The function call is:
Public Function ConvertReportToPDF( _
Optional strReport As String = "", _
Optional SnapshotName As String = "", _
Optional strDocName As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 150, _
Optional PasswordOpen As String = "", _
Optional PasswordOwner As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0, _
Optional PDFUnicodeFlags As Long = 0 _
) As Boolean
End Function

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

Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"

With rs
Do Until (.EOF Or .BOF) = True
strDocName = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\ " & !SiteName & ".pdf"

Dim qdf As DAO.QueryDef

Set qdf = db.QueryDefs("qrySchools")
qdf.SQL = "SELECT * FROM tblStudentDataSheet_0708 WHERE
School= " & rs("School")
qdf.Close
Set qdf = Nothing
blRet = ConvertReportToPDF(strReport, vbNullString,
strDocName, False, False)
rs.MoveNext
Loop
End With

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
 
M

Mark A. Sam

Could this be the problem?

Do Until (.EOF Or .BOF) = True

Try

..MoveFirst
Do Until .EOF = True


God Bless,

Mark A. Sam

This this method is valid, then won't it bomb out becuase .BOF will be true?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top