Printing a report query using a "print" button on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josephbupe
    New Member
    • Jan 2008
    • 7

    Printing a report query using a "print" button on a form

    Instead of going to file>Print, i need a form with a "print" command button to print reports that have been queried.

    What code and how is it used for this.

    I will appreciate.

    Regards.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Originally posted by Josephbupe
    Instead of going to file>Print, i need a form with a "print" command button to print reports that have been queried.

    What code and how is it used for this.

    I will appreciate.

    Regards.
    Hi Joseph. The Access command button wizards will create the code for you if what you need is to print a particular report, or output the current contents of a form to a printer. The code the wizard's generate can then be modified if need be to meet more specific requirements.

    If, for whatever reason, you are creating the printer button code manually, you could place one of the code lines below in the on-click event of the button on your form.
    [code=vb]DoCmd OpenReport "reportname ", acPreview[/code]This opens a specific report in print-preview mode. You would need to replace reportname with the name of the actual report.

    [code=vb]DoCmd.Printout[/code]This simply prints the current form contents to a printer, exactly as it looks on the screen.

    -Stewart

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Be aware that DoCmd.Printout prints out all the records in the form, not just the current record! This can be quite startling if you have a Single View Form and use it, thinking you're getting just the record you're looking at when in reality you're getting all 10,000 records, one to a page!

      Linq ;0)>

      Comment

      Working...