Loop through recordset of form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jean004
    New Member
    • Jan 2012
    • 3

    Loop through recordset of form

    I have a form and a subform. I have a button on the form to export to pdf a report. However I currently have to go through every record on the main the form and press the button to export the report specific to that particular report. How can I get my code to run through each record on the main form?

    Private Sub Command15_Click ()
    On Error GoTo Err_Command15_C lick

    Dim stDocName As String

    stDocName = "Contract Status Report with Open IR"
    DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "CC" & Me.CC & " " & stDocName & " P9 as of January 6th 2012.PDF"

    Exit_Command15_ Click:
    Exit Sub

    Err_Command15_C lick:
    MsgBox Err.Description
    Resume Exit_Command15_ Click

    End Sub
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What's the record source for the report?

    Comment

    • jean004
      New Member
      • Jan 2012
      • 3

      #3
      the recordsource of the form I am using to preview data is CostCentre - ENG

      the recordsource of the report I am using is
      CostCentre - ENG Query

      however the recordsource of the report has a criteria:
      [Forms]![REPORT PREVIEW/PRINT]![CC]

      Hope this helps.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Take out the criteria and the report will have all the records.

        Comment

        • jean004
          New Member
          • Jan 2012
          • 3

          #5
          What I am wanting to accomplish is for the system to extract a pdf of the report per record. If follow what you say, it will only extract all the current reports i am extracting manually into a single report, not what I want. I want the code to extract all reports in pdf for each record on my form.


          Imagine many business unit managers needing their own individual report of the performance of their unit. The report layout and information is the same for all. However the information is specific to them and they each only see their information.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            In that case, use a Do Until loop on the recordset.

            Comment

            Working...