Printing Individual PDF Reports

D

dawn_dudley

I have tried two sets of codes for printing individual Access reports to PDFs
that I can not get to work. Your help would be most appreciated.

First:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = DBEngine(0)(0)
Set rst = dbs.OpenRecordset("SELECT DISTINCT [ID] from qryEID",
dbOpenSnapshot)
Do Until rst.EOF
DoCmd.OpenReport "AE_Statement_05012008", , , "[Bonusemp] = " & rst![ID]
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set dbs = Nothing

I get the error "Invalid Outside Procedure" when I run in.

Two:

Sub Test()
On Error GoTo ProcError

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryEID", dbOpenSnapshot)

With rs
Do Until (.EOF) = True
DoCmd.OpenReport "AE_Statement", View:=acViewNormal, _
WhereCondition:="ID = " & rs("ID")
rs.MoveNext
Loop
End With

ExitProc:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine "
Resume ExitProc
End Sub

Asks me for ID numbers and where to save the data.

I would like it to run without input, all the statements to individual
reports for distribution. I am probably just not understanding the process.
Thank you in advance for any help you can give me.
 
L

Larry Linson

Just as a matter if interest, why are you opening a Recordset? The Report's
Record Source property associates it with a source of data, and just having
a recordset open does not affect the Report.

Larry Linson
Microsoft Office Access MVP
 
D

dawn_dudley

I am simply copying from Tom Wickerath's response to "Printing reprots from
Access to PDF" and trying to get it to work for me.

Larry Linson said:
Just as a matter if interest, why are you opening a Recordset? The Report's
Record Source property associates it with a source of data, and just having
a recordset open does not affect the Report.

Larry Linson
Microsoft Office Access MVP


dawn_dudley said:
I have tried two sets of codes for printing individual Access reports to
PDFs
that I can not get to work. Your help would be most appreciated.

First:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = DBEngine(0)(0)
Set rst = dbs.OpenRecordset("SELECT DISTINCT [ID] from qryEID",
dbOpenSnapshot)
Do Until rst.EOF
DoCmd.OpenReport "AE_Statement_05012008", , , "[Bonusemp] = " & rst![ID]
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set dbs = Nothing

I get the error "Invalid Outside Procedure" when I run in.

Two:

Sub Test()
On Error GoTo ProcError

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryEID", dbOpenSnapshot)

With rs
Do Until (.EOF) = True
DoCmd.OpenReport "AE_Statement", View:=acViewNormal, _
WhereCondition:="ID = " & rs("ID")
rs.MoveNext
Loop
End With

ExitProc:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine "
Resume ExitProc
End Sub

Asks me for ID numbers and where to save the data.

I would like it to run without input, all the statements to individual
reports for distribution. I am probably just not understanding the
process.
Thank you in advance for any help you can give me.
 

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