Open Report Based on Multiple Combo Box Selections (Access, VBA) - vba

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!!

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

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

Related

How do I open an MS-Access report with a subset of the recordsource data?

I have a query that produces a recordset that I use for a computer generated invoice that I have created with an MS Access report. The recordset looks something like this (but with hundreds of invoices):
ControlNumber|ShippingAddress|InventoryDescription|...
17-001 123 Fake St Description A
17-002 145 No addr Description B
17-003 23456 new st Description C
I have the report set up so it will generate me separate completely filled out invoices on a different page for every invoice in the system. I don't want to have to hunt through hundreds of them to find the specific one I want to print, though.
I have another MS Access form that the operator uses to select which of these invoices to print with a drop down combo box, and a button. After I use the dropdown to choose which one I want to print (say 17-003), I want to hit the button and have the report pop up with only that one single invoice. How do I tell the report to only show me a subset of that recordset?
I am fine with using existing Access functions or with writing VBA code if necessary, but I would prefer to not default to VBA if possible.
Options for dynamic filtering of report dataset:
dynamic parameterized query as the report RecordSource, this can be a popup input or reference to a control on form - I never use dynamic parameterized queries
manually open report in design view and set the Filter property then switch report to print preview then print
code (macro or VBA) applies filter when report opens by referencing control on form, example VBA: DoCmd.OpenReport "report name", , , "ControlNumber='" & Me.cbxCN & "'"

Limit Combobox input based on other control on same form

I have a database in access for which I made some forms, which is going pretty well.
I only have one small issue I am running into.
I have this form on which I have several comboboxes, which get their Row source from another table. That is working fine.
But for combobox B I wanted the options limited/filtered based on the selection in combobox A. So I filled the following in the row source of combobox B:
SELECT JOBS.Numbers
FROM JOBS
WHERE CITY = Me.CITY
So there is another combobox on the same before where the CITY is picked.
Now when open combobox B it asks me to fill in the city manually and then it filters/limits the options in the way I want. However, I want this to happen automatically based on the selection in combobox A (on the same form).
I hope you can help me.
Thanks in advance.
I find this feature very useful. For example I have a form where project managers select there name from a combobox(A) then in the next box(B) select their project. B uses the criteria from the first box to only list their projects.
Specifically the project table I pull the list from has an owner field. I use the name entered into A as criteria on the Owner to pull just their projects.
On the combobox query build I input the Owner criteria like this. The query runs then with whatever data is entered into boxA.
Forms![Main]![cboOwner]
On the first combo box "After Update" event add Me.ComboboxB.Requery. That will make combo box B refresh its contents based on the current value of combo box A every time A's value is changed.

Linked Combobox

Is it possible to have the same combobox appear on multiple forms with linked selections?
I have several forms used for data entry and on the Main form (which has links to the other forms) there are two comboboxes, one queries Year and the other Branch. Based on the selections of these two combo boxes the other forms with apply filters on activate so that users can enter data for their specific branches.
What I am trying to do is have the same comboboxes appear on all the forms so that users don't have to go back to the main form to change the year or branch.
What you're saying is this:
On Form A the user would choose the year and the branch.
On form B their selection would continue to appear.
Option 1: If they can change it in form B you need to copy the value (set the default value) when you launch form B.
Option 2: if they can't change it in form B just put the value inside a (locked) text box, so they will see what the year was but they wouldn't be able to change it.

How to program crystal report to lookup a record in a table

i Have a Table with Fields
Material Number
Order Code
Supplier Code
Description
I have a crystal reports rpt file that i manually enter all the information to generate labels.
I am trying to program this using the built in formula editor, so when i enter the Material Number (which is a unique code) it will automatically display other 3 relevant fields.
I have tried few formulas in the formula editor without any luck.
can anyone help?
relliK
UPDATE
#Siva - I have added the table for clarification
i simply want a lable printed with only one user input being the Material Number, and then the code/fomula in crystal reports to fetch the other data based on the Materila number and produce the label.
thank you for you interest in this issue.
UPDATE
#Siva - I have added a sample label, i would only want to enter 20506871 as Material and the other data fields to be pulled from excel
not sure if i can use parameter fields and/or i would like some help on programming the parameter fields

Access 2007 - drop down box in a Report

I need to create a drop-down box so that an employee can select a pre-set reason in the "RE:" field of a Report. There are only two selections that need to be in the box: "personal events" and "lack of adequate notice".
The report itself is already made and there are a number of fields that link back to the database - name, address, specific dates, etc that are already in the report. I've figured out how to make the drop-down box using the combo box function in a form but is there any way I can merge the combo box into the report?
I'm a beginner, by the way so I'm still figuring things out.
Currently your report sits on a query (query get relevant data from the table)
Steps to follow:-
Change the table by adding a column with the two options you just
mentioned above
Add combobox to Form with items as the two options
Adjust your query to use these options as a criteria to change
results returned by the query
Show the results in the report as you are showing right now.
If you have a code already, please post that snippet. So we can help you accordingly.
Some reference for you to get ideas
BUT I HAVE A DOUBT, ARE YOU TRYING TO SAY YOU WANT TO SWTICH BETWEEN TWO REPORTS BASED ON THE USER CHOICE SELECTED IN COMBOBOX?