Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2002
    Posts
    7

    Unanswered: Passing value from form to report before print

    Hi all,

    I have a form that has a button to print a report. I would like the user to be able to enter the number of copies to be printed of the report AND have that number appear in a field on the report itself as well (for jurisdictional reasons).

    I have been trying but not succeeded... this is what I came up with so far. Could anyone point me in the proper direction to finish it?

    Private Sub cmdPrintLoadform_Click()

    NumberOfCopy = InputBox("How many copies need to be printed?", "Number of copies")

    DoCmd.OpenReport ("rptLoadform")

    DoCmd.PrintOut acPrintAll, , , , NumberOfCopy
    DoCmd.Close

    End Sub

  2. #2
    Join Date
    Nov 2002
    Posts
    150

    Re: Passing value from form to report before print

    Originally posted by Tonco
    Hi all,

    I have a form that has a button to print a report. I would like the user to be able to enter the number of copies to be printed of the report AND have that number appear in a field on the report itself as well (for jurisdictional reasons).

    I have been trying but not succeeded... this is what I came up with so far. Could anyone point me in the proper direction to finish it?

    Private Sub cmdPrintLoadform_Click()

    NumberOfCopy = InputBox("How many copies need to be printed?", "Number of copies")

    DoCmd.OpenReport ("rptLoadform")

    DoCmd.PrintOut acPrintAll, , , , NumberOfCopy
    DoCmd.Close

    End Sub
    Might be a better way to do this, but it works
    1) create a global variable in a module: Global NumberOfCopies As Integer

    2) Set NumerOfCopies to the value the user enters: NumberOfCopies = InputBox("How many copies need to be printed?", "Number of copies")

    3) Place a control on your report and set it in the Report_Open event:

    Private Sub Report_Open(Cancel As Integer)
    Me.Label0.Caption = NumberOfPages
    End Sub

  3. #3
    Join Date
    Nov 2002
    Posts
    7
    And again you've helped me greatly. The labels work great.

    One problem left now... I can't get the report to print the number of times I specify in NumberOfCopy.

    I don't know how to pass it to some print option. When I put the line:

    DoCmd.PrintOut acPrintAll, , , , NumberOfCopy

    in the Open event of the report, it gives me an error because it can't be executed when processing the report.

    If I put the line in the button of the form's event, it prints the form itself...

    hope you could help me out here one more time

  4. #4
    Join Date
    Nov 2002
    Posts
    150
    Originally posted by Tonco
    And again you've helped me greatly. The labels work great.

    One problem left now... I can't get the report to print the number of times I specify in NumberOfCopy.

    I don't know how to pass it to some print option. When I put the line:

    DoCmd.PrintOut acPrintAll, , , , NumberOfCopy

    in the Open event of the report, it gives me an error because it can't be executed when processing the report.

    If I put the line in the button of the form's event, it prints the form itself...

    hope you could help me out here one more time
    Use DoCmd.OpenReport and then DoCmd.PrintOut in the method where you capture the number of copies to print:

    DoCmd.OpenReport "<report name>", acViewPreview
    DoCmd.PrintOut acPrintAll, , , , NumberOfPages

  5. #5
    Join Date
    Nov 2002
    Posts
    7

    It's working.

    Hi,

    thanks a zillion again. It's working completely as it should now. I didn't set the acViewPreview parameter before.

    Tonco.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •