0
votes

I have a set of reports stored in Access, and I am trying to generate a specific report based on multiple combo box selections and a "run report" button on a form.

For this example, Combo Box 1 = Location, and Combo Box 2 = Report Type.

Suppose I choose Toronto from Location, and Sales from Report Type. This means I'd like to generate the Sales Report for Toronto.

I have two issues - 1 major and 1 minor.

Major issue: I can currently only generate reports based on 1 combo box selection. My code is as follows:

DoCmd.OpenReport Forms!Form1!Loc, acViewPreview, , "[Loc]='Toronto'"

In order for this to work, I would need to have my sales report named as "Toronto". For the purpose of checking the code, I did that and it worked. However, I am trying to use multiple combo boxes and need more complex naming for my reports. How can I make it so that the code pulls the selection from multiple combo boxes and generates the corresponding report?

Minor issue:

When running the report, I get a popup message that asks me to specify location again:

location popup

How can I prevent this popup from appearing?

Any help is greatly appreciated!!

2

2 Answers

0
votes

Are you using a query ? is the best option to do that.

0
votes

that box that pops up is because you are trying to open the report but the data to the field "loc" is missing.