Filtering a report based on combo box selection

sc2227

New member
Local time
Yesterday, 21:49
Joined
Mar 5, 2017
Messages
9
Hello,

I am having trouble with a step in my form. I have attached the database (Access 2016 is used) in this post.

Please open "data_entry form" which has 3 drop down menus. Select an option in first two drop down menus, and click the command buttons next to the menus (I had to add command buttons or else it wouldn't refresh the menus properly), then finally select an option in the third menu (it filters based off of first two menus choices).

When you click Open Report, it should only bring up the records you selected as criteria based in the drop down menu in a Print Preview report. Instead it brings up all records and doesn't filter on the selections in the drop down menus. What do I do to filter it for the criteria selected?

I have created a queryMaster and I believe I am supposed to add in a filter in here, but I don't know how to write it. Also, I have a Tbl_Master which is the master information list, but the form currently doesn't pull anything from this table, it pulls from other tables. I will need it to pull from Tbl_Master afterwards because I have duplicates and can't have a primary key as I have it now. I will do that later. For now, I just need a report generated based on the criteria I selected from the form drop down. I searched through numerous youtube videos and still stuck. thanks in advance.

Please let me know if you need any more information.

Please help as it is urgent and last step I am stuck on.
 

Attachments

if you have 1 combo box, make the query use it. The report uses the query.
The query would be like:
select * from table where [field]=forms!myform!cboBox

Code:
sub btnPrint_click()
if IsNull(cboBox) then
   docmd.openreport "rptAllRecs", acViewPreview 
else
   docmd.openreport "rptFilteredRecs",acViewPreview 
endif
end sub
 
I will try that code thanks. But as I have 3 combo boxes and not 1, where should I enter this code? Do I have 1 query if have three combo boxes? How to set this up, please advise.
 
If all 3 are cascading, they do the same,
Cbo1 refreshes 2,
Cbo2 refreshes 3,
Etc.

In the AFTERUPDATE event.
 
Thank you.

I am a beginner and not experienced in the coding. Instead I went to Design View in Query to select and enter in a criteria there.

I attached an updated database.Please open 'data entry' form and make selections in the drop down. Please make sure to click on the buttons next to the drop downs as I had to do this to ensure the menus refreshed properly.

When you click on Open Report button, it only opens an empty report. It doesn't create a report based on the information selected in the drop down menus. If you open my query in Design View, you will see the criteria I wrote. I placed the same criteria for all the drop down menus.

Where is it going wrong? Where do I update? Please advise. Again, I am a beginner and in Design View I can understand you most.

This is the last step of my report generation and urgent. If I can bring up a report based on drop down menu selections, it will be complete. thank you.
 

Attachments

For showing you the differences I've copied the querier, form and report and add JHB to the name.
 

Attachments

Users who are viewing this thread

Back
Top Bottom