Josh said:
I have a form with 20 reports on it. Currently there are also 20
preview buttons(1 for each report). Is it possible for me to create 1
button that will run all reports? I have a checkbox(in an option group)
next to each report. So if the checkbox is checked the print button
should print the checked report. How would i go about coding the button
for this?
Thanks
Using an Option Group is one way.
Code the Command Button's Click event:
Dim strReport as String
Select Case OptionGroupName
Case is = 1
strReport = "SomeReport"
Case is = 2
strReport = "Another Report"
etc.....
End Select
DoCmd.OpenReport strReport, acViewPreview
The difficulty with this approach is you are limited to the reports at
the time the event code is written. If a report is later added to (or
removed from) the database, you must re-write the Command Button event
code.
Another approach might be to use a ComboBox to list all the reports in
the database. Add a new one, and it automatically gets added.
As Combo Box RowSource:
SELECT MSysObjects.Name FROM MSysObjects WHERE (((Left([Name],1))<>"~")
AND ((MSysObjects.Type)=-32764)) ORDER BY MSysObjects.Name;
Then you would simply code the Combo Box AfterUpdate event:
DoCmd.OpenReport Me!ComboName, acViewPreview
and not bother with the command button.
It would certainly take up much less space than a 20 button option
group, and requires no additional maintenance.