Trying to make this code work, don't know how to filter as it prints identical all reports.
Private Sub cmdExportPDF_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyPath As String
MyPath = "C:\Reports"
If Len(Dir(MyPath, vbDirectory)) < 1 Then
MkDir (MyPath)
End If
Dim sProjectNumb As String
Dim sProjectName As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT ProjectNumb, ProjectName FROM Master", dbOpenSnapshot)
If rs.RecordCount = 0 Then Exit Sub
Do While Not rs.EOF
sProjectNumb = rs![ProjectNumb]
sProjectName = rs![ProjectName]
MyFileName = sProjectNumb & " " & sProjectName & ".PDF"
DoCmd.OpenReport "Total Report", acViewDesign, , "[ProjectNumb]=" & temp
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFileName
DoCmd.Close acReport, "Total Report"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub cmdExportPDF_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyPath As String
MyPath = "C:\Reports"
If Len(Dir(MyPath, vbDirectory)) < 1 Then
MkDir (MyPath)
End If
Dim sProjectNumb As String
Dim sProjectName As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT ProjectNumb, ProjectName FROM Master", dbOpenSnapshot)
If rs.RecordCount = 0 Then Exit Sub
Do While Not rs.EOF
sProjectNumb = rs![ProjectNumb]
sProjectName = rs![ProjectName]
MyFileName = sProjectNumb & " " & sProjectName & ".PDF"
DoCmd.OpenReport "Total Report", acViewDesign, , "[ProjectNumb]=" & temp
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFileName
DoCmd.Close acReport, "Total Report"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub