Sub PrintReport Dim rs As DAO.Recordset
'Needs reference to Microsoft DAO 3.6 Object Library
Set rs=CurrentDB.OpenRecordset("tblParts")
'The query for the report
qdf=CurrentDB.QueryDefs("qryPartReport")
strSQLSave=qdf.SQL
Do While Not rs.EOF
'Let us say that there is no where statement
'in the SQL and that the PartNo field
'is numeric
strWhere = " Where PartNo=" & rs!PartNo
qdf.SQL=strSaveSQL & strWhere
'Let us say that the printer is set up
DoCmd.OpenReport "rptPartNo", acViewNormal
'Rename the report
Name "C:\Docs\rptPartNo.pdf" As "C:\Docs\" & rs!PartNo & ".pdf"
rs.MoveNext
Loop
'Put the query back the way it was
qdf.SQL=strSQLSave