471,337 Members | 988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

printing multiple reports

First of all, I'm a nebie at VB code.......so be gentle.
I need to print up to 25 reports at the click of a button, but I want to select which reports to print based on whther or not I have a check box ticked.
I already have a simple form that shows every report name, and beside the name is a Yes/No tick box to indicate if I want that particular report printed when I click the main print command button.
I don't want to have a print command button for every report, only one.
I may only want 1 or any combination of all 25 reports printed, but the only criteria for printing them will be the Yes/No box.
How do I write the VB code for my print command button to do this?

For argument sake, you can call them Report1, Report2, Report3, and so on.

Thanks,

Rush2112
Mar 13 '07 #1
3 1928
MMcCarthy
14,534 Expert Mod 8TB
Remove the check boxes and add a listbox instead.
Under the data tab set the listbox RowSourceType to "Value List" and the Row Source to "Report1";"Report2";"Report3";"Report4";...etc . Under the other tab set the multi-select property to simple. This will allow users to select multiple options from the list by holding down the Ctrl button.

Assuming command button is cmdPrint and list box is lstReports.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPrint_Click()
  2. Dim valSelect As Variant
  3.  
  4.    ' Print each report selected in the list
  5.    For Each valSelect In Me.lstReports.ItemsSelected
  6.       DoCmd.OpenReport Me.lstReports.ItemData(valSelect), acViewPreview
  7.    Next valSelect
  8.  
  9. End Sub
  10.  
I have used acViewPreview as it will show the report to screen and user can manually print. However, if you just want the report to print then use acViewNormal.

Mary
Mar 13 '07 #2
That worked perfect.
Thanks very much Mary.

Rush2112
Mar 13 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
That worked perfect.
Thanks very much Mary.

Rush2112
No problem, glad I could help.
Mar 13 '07 #4

Post your reply

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

Similar topics

2 posts views Thread by Sigurd Bruteig | last post: by
1 post views Thread by John | last post: by
4 posts views Thread by Russ | last post: by
1 post views Thread by Stinky Pete | last post: by
5 posts views Thread by dancole42 | last post: by
18 posts views Thread by Brett | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.