one command button to run multiple reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command button on my form that I want to be able to run several
reports from. I have a combo box that contains the values that I want to use
to determine which report is run.

For example:

My reports are Grand Total - 12 Months; Grand Total - 6 Months; Grand Total
- 3 Months.

The combo box values are 12 Months; 6 Months; 3 Months.

How can I accomplish this?

Any assistance is greatly appreciated!
 
In the After Update event enter

Dim strDocName as string

strDocName = "Grand Total - " & me.YourComboBoxName
DoCmd.OpenReport strDocName

-> This will print the report
If you want to view it first type:
DoCmd.OpenReport strDocName, acViewPreview
 
I have a command button on my form that I want to be able to run several
reports from. I have a combo box that contains the values that I want to use
to determine which report is run.

For example:

My reports are Grand Total - 12 Months; Grand Total - 6 Months; Grand Total
- 3 Months.

The combo box values are 12 Months; 6 Months; 3 Months.

How can I accomplish this?

Any assistance is greatly appreciated!

Code the Command button Click event:
Dim DocName as String
Select Case ComboBoxName
Case "12 Months"
DocName = "Grand Total - 12 Months"
Case "6 Months"
DocName = "Grand Total - 6 Months"
Case Else
DocName = "Grand Total - 3 Months"
End Select

DoCmd.OpenReport DocName, acViewPreview

The above will do what you want, however it makes it more difficult to
change the report names or add additional reports.

You might want to consider creating a table with the report names and
use the table as rowsource for the combo box. Then it's quite easy to
change the reports or add a new report to the list. Just do it in the
table. No user programming skills required.

tblReports
Report Name Short Name
Grand Total - 3 Months 3 months
Grand Total - 6 Months 6 months
Grand Total - 12 Months 12 months

Set the Bound column to Column 1.
Set the Column Width to 0";1"

Set the Combo RowSourceType to Table/Query
Set the Rowsource to:
Select tblReports.ReportName, tblReports.ShortName From tblReports
OrderBy Val(tblReports.ShortName);


Then simply code the command button click event:

DoCmd.OpenReport Me![ComboName], acViewPreview
 
Thanks for your response but of course I have questions.

Do I put this in the Command Button event?

Do I enter this for each report?

In order to do this, do I have to have my reports names the same as the
corresponding values in the combo box?

Thanks again!
 
Thanks Fred! I appreciate your response and I think I understand what to do
now.

fredg said:
I have a command button on my form that I want to be able to run several
reports from. I have a combo box that contains the values that I want to use
to determine which report is run.

For example:

My reports are Grand Total - 12 Months; Grand Total - 6 Months; Grand Total
- 3 Months.

The combo box values are 12 Months; 6 Months; 3 Months.

How can I accomplish this?

Any assistance is greatly appreciated!

Code the Command button Click event:
Dim DocName as String
Select Case ComboBoxName
Case "12 Months"
DocName = "Grand Total - 12 Months"
Case "6 Months"
DocName = "Grand Total - 6 Months"
Case Else
DocName = "Grand Total - 3 Months"
End Select

DoCmd.OpenReport DocName, acViewPreview

The above will do what you want, however it makes it more difficult to
change the report names or add additional reports.

You might want to consider creating a table with the report names and
use the table as rowsource for the combo box. Then it's quite easy to
change the reports or add a new report to the list. Just do it in the
table. No user programming skills required.

tblReports
Report Name Short Name
Grand Total - 3 Months 3 months
Grand Total - 6 Months 6 months
Grand Total - 12 Months 12 months

Set the Bound column to Column 1.
Set the Column Width to 0";1"

Set the Combo RowSourceType to Table/Query
Set the Rowsource to:
Select tblReports.ReportName, tblReports.ShortName From tblReports
OrderBy Val(tblReports.ShortName);


Then simply code the command button click event:

DoCmd.OpenReport Me![ComboName], acViewPreview
 
Back
Top