how to stop form from printing when printing a report from form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ketchu1j
    New Member
    • Oct 2015
    • 3

    how to stop form from printing when printing a report from form

    I have been trying to use a command button in Access to print a report to the default printer without showing the printer selection screen first. I finally got it to do that using the following code that I found from someone else on your site...

    Code:
    Private Sub Command29_Click()
    2.     DoCmd.OpenReport "rpt_stamp_label", acViewNormal, , , acHidden
    3.     DoCmd.PrintOut acPrintAll
    4.     DoCmd.Close acReport, "rpt_stamp_label"
    5. 
    6. End Sub
    The problem I am having is that each time it prints the report, it also prints out a screen shot of the form that the button is activated from. Can anyone help me so that only the report prints?
  • ketchu1j
    New Member
    • Oct 2015
    • 3

    #2
    Found the answer on another forum site. The secret was to remove the DoCmd.PrintOut acPrintAll line altogether. It still prints without the printer selection pop-up window showing up and does not print the form where the print function button was clicked. Success!!

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      The problem was that you opened your report in the "hidden" and "Normal"
      Code:
      DoCmd.OpenReport "rpt_stamp_label", _
         [icode]acViewNormal[/icode], _
          , _
          , [icode]acHidden[/icode]
      This sent your report directly to the printer and closed the report.
      Once closed the focus returned to your form. With the acPrintAll option in the print command it cause the controls as well as any records to print.

      Simply, lines 3 and 4 are not needed.

      Comment

      Working...