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

printing multiple reports

P: 4
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
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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

P: 4
That worked perfect.
Thanks very much Mary.

Rush2112
Mar 13 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
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.