I am now learning recordsets and how they can be used.
My code below is supposed to open a table and loop thru it and create a PDF of the 2-page report for each record. The only part that is not working a intended is that the PDF being generated is for all the records that comes before the rs edit.
So the first PDF will have all records in the rs, then next PDF will have all except the first record, etc etc
Please review for guidance.
My code below is supposed to open a table and loop thru it and create a PDF of the 2-page report for each record. The only part that is not working a intended is that the PDF being generated is for all the records that comes before the rs edit.
So the first PDF will have all records in the rs, then next PDF will have all except the first record, etc etc
Please review for guidance.
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strINTCODE As String
Dim strNewPDF as string
Dim strSQL as string
strSQL = "SELECT * FROM Employees WHERE PerformanceRating IS NULL"
strNew PDF = DoCmd.OutputTo acOutputReport, "Performance Plan", acFormatPDF, "PATH\" & strEMPID & " Performance Plan " & Format(Date, "mmddyyyy") & ".pdf", False
Set db = CurrentDb
'Open the recordset for use (table, Query, SQL Statement)
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
'If the table is empty, exit.
If rs.EOF Then
'Display message to user
MsgBox "There are no pending plans to be generated.",,"No Pending Plans"
Exit Sub
'Initialize counter
counter = 1
If Not (rs.BOF And rs.EOF) Then
rs.MoveFirst
Do Until rs.EOF
strINTCODE = rs("INTCODE")
strNewPDF
rs.Edit
rs!PerformancePlan = "EmpID-" & strEmpID & "-2014"
rs.Update
rs.MoveNext
counter = counter + 1
Loop
End If
rs.Close