I was given a database and asked to create a report on 3 business segments. Then edit the code within the module to generate an individual report for each of the 3 business segments.
Issue: I have edited the module and it produces 3 reports, however the data is not filtering by each business sement, each of the 3 reports contains the data for all 3 business segments. Below is the code I am working with:
Function CreateReports()
Dim db As DAO.Database, db1 As DAO.Database
Dim rcs As DAO.Recordset, rcs1 As DAO.Recordset
Dim num, num1
Set Application.Printer = Application.Printers("Adobe PDF")
Set db = CurrentDb
Set rcs = db.OpenRecordset("tblDivision", DB_OPEN_DYNASET)
Do Until rcs.EOF
num = rcs![division]
report_name = "division_" & rcs![division]
DoCmd.OpenReport "Report1", acViewDesign, "[Division]=" & num, acHidden
Reports("Report1").Caption = report_name1
Reports("Report1").Filter = "[Division] = " & Chr(34) & num & Chr(34)
DoCmd.Close acReport, "Report1", acSaveYes
DoCmd.OutputTo acOutputReport, "Report1", acFormatPDF, "C:\Test Exercise\division_" & rcs![division] & ".pdf", False
Set Application.Printer = Nothing
rcs.MoveNext
Loop
End Function