By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 926 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

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

P: 7
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.
Mar 7 '08 #1
Share this Question
Share on Google+
2 Replies


Expert Mod 2.5K+
P: 2,545
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.
Expand|Select|Wrap|Line Numbers
  1. DoCmd OpenReport "reportname", acPreview
This opens a specific report in print-preview mode. You would need to replace reportname with the name of the actual report.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Printout
This simply prints the current form contents to a printer, exactly as it looks on the screen.

-Stewart
Mar 7 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
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)>
Mar 7 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.