locked
Print Report with Changing Value RRS feed

  • Question

  • Hello, everyone, I'm new here. I hope you can help me.

    I have this form

    And it prints a report N times according to the number in the "# Copias" box with

        DoCmd.SelectObject acReport, "rpt_Tracker", True
        DoCmd.PrintOut , , , , Me.txt_Copias

    This is the report gets the values on the form and prints them


    What I would like to do is print my report but every time have a different box number increasing +1 

    For example, if my form says BOX 50, # COPIAS 30, the first printed report should say BOX 50 and the last (the 30th) should say BOX 79

    Any idea on how I can achieve this?

    (sorry I can't post images)

    Monday, April 13, 2020 6:57 PM

Answers

  • Rather than calling the PrintOut method try printing a separate copy of the report at each iteration of a For…Next loop.  In the loop firstly increment the value of a hidden text box in the form by 1, and then call the OpenReport method.  In the report reference the hidden text box in the form to assign its current value to a text box control.

    PS:  An alternative to a hidden text box would be to pass the incremented value to the report as the OpenArgs argument of the OpenReport method.  The value of the report's OpenArgs property could then be assigned to a text box control in the report's Open event procedure.

    Ken Sheridan, Stafford, England


    • Edited by Ken Sheridan Monday, April 13, 2020 10:41 PM Postscript added.
    • Marked as answer by Ramirez525 Monday, April 13, 2020 10:56 PM
    Monday, April 13, 2020 10:37 PM

All replies

  • Rather than calling the PrintOut method try printing a separate copy of the report at each iteration of a For…Next loop.  In the loop firstly increment the value of a hidden text box in the form by 1, and then call the OpenReport method.  In the report reference the hidden text box in the form to assign its current value to a text box control.

    PS:  An alternative to a hidden text box would be to pass the incremented value to the report as the OpenArgs argument of the OpenReport method.  The value of the report's OpenArgs property could then be assigned to a text box control in the report's Open event procedure.

    Ken Sheridan, Stafford, England


    • Edited by Ken Sheridan Monday, April 13, 2020 10:41 PM Postscript added.
    • Marked as answer by Ramirez525 Monday, April 13, 2020 10:56 PM
    Monday, April 13, 2020 10:37 PM
  • Thanks. That works.

    It takes a bit longer than PrintOut but it gets the job done

    Monday, April 13, 2020 10:56 PM