Hey everyone, I have a access database that generates PDF form letters (or at least should if I wasn't crap at coding)
The code is supposed to take the query, and loop through creating a pdf of each entry and saves them by the officer name and date of the incident.here's the code I have so far:
Code:
Private Sub Command75_Click()
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim strSQL As String
Dim strRptName As String
Dim count As Integer
strRptName = "Report"
strSQL = "Select [Main Table].[ID] From [Police Departments Query];"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
With MyRS
Do While Not MyRS.EOF
DoCmd.OpenReport strRptName, acViewPreview, , "[ID]=" & ![ID]
DoCmd.OutputTo acOutputReport, strRptName, acFormatPDF, [Application].[CurrentProject].[path] & "\Aed letters\" & "Aed Letter " & [Officer Name] & " " & Format([Date of Incident], "MMMM dd, yyyy") & ".pdf"
DoCmd.Close acReport, strRptName, acSaveNo
.MoveNext
Loop
End With
MyRS.Close
Set MyRS = Nothing
End Sub
Now it loops through, however it doesn't seem to change the query so it just creates the same pdf
Any suggestions on how to make this work or links to working code? thanks!