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.
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.