473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I open a report based on a ComboBox selection?

Seth Schrock
2,965 Expert 2GB
I have a database that is keeping track of returned mail. Each piece of returned mail has a status. I want to be able to view reports for all the returned mail in each status. I could create a button for each, but I would rather select the report from a ComboBox or ListBox. I have the combobox getting its values from a statuses query. I don't know if this is too complicated, but I would like for it to work like this: Select a status from the combobox, click a submit button or run something in the AfterUpdate event that creates a query for just the status that I selected and then have it build a report from the query. The report would be built off of a template. I vagely remember something about being able to create a query that asked for a selection criteria and then ran the query. Is it possible to do something like this and have the criteria be assigned by the combobox?
Apr 13 '11 #1

✓ answered by beacon

Hi Seth,

Take a look at this tutorial: http://www.fontstuff.com/access/acctut08.htm

You can use the general idea to accomplish what you've set out to do. If different selections on your form will require different report "templates", you'll just use a conditional statement (like If...Then...Else, or Select Case) to determine which report to call, and then call it.

You could build a query on demand, but I've found it's easier to consider the possibilities for each item in the combo box and try to create an individual query for each...unless, of course, you want to use the same query and just filter the results based on the parameter passed from the form (which is what the tutorial explains).

Hope this helps,
beacon

4 30902
beacon
579 512MB
Hi Seth,

Take a look at this tutorial: http://www.fontstuff.com/access/acctut08.htm

You can use the general idea to accomplish what you've set out to do. If different selections on your form will require different report "templates", you'll just use a conditional statement (like If...Then...Else, or Select Case) to determine which report to call, and then call it.

You could build a query on demand, but I've found it's easier to consider the possibilities for each item in the combo box and try to create an individual query for each...unless, of course, you want to use the same query and just filter the results based on the parameter passed from the form (which is what the tutorial explains).

Hope this helps,
beacon
Apr 14 '11 #2
Seth Schrock
2,965 Expert 2GB
This was exactly what I was looking for. It told me how to create the report that would pull its criteria from a combo box by putting this in the criteria field:[Forms]![frmReportbyStatus]![cboSelectStatus]. I then created a report that was based on the query. Here is the code that I ended up with:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSelectStatus_AfterUpdate()
  2.     DoCmd.OpenQuery "qryPeopleStatus", acViewNormal, acEdit
  3.     DoCmd.OpenReport "People", acViewReport
  4.     DoCmd.Close acQuery, "qryPeopleStatus"
  5.     DoCmd.Close acForm, "frmReportbyStatus"
  6. End Sub
In the After Update event of the combo box, it runs the query and then opens the report. The report is the populized with the correct information. Then you close the query (which will be left open if you don't do this) and then close the dialog box. Works like a charm.
May 9 '11 #3
Sorry, I am relatively new to this. Would this code not just always pull the report names and query names you have within it? What if you have two or three different reports to pull from the combo box, wouldn't the Code always pull the same report?

I guess I am missing how the criteria code decides the query to be generated and then the report.

Thanks, this has been helpful!


@Seth Schrock
Nov 1 '15 #4
zmbd
5,501 Expert Mod 4TB
Edgarc1981: You need to follow the link in Post#2 and follow the tutorial.

In summary:
+ The same query is called; however, the criteria changes based on the control's value.... say we're looking for blue t-shirts for a sales report one time and a red t-shirts at a different time. Same query, different criteria for the search.

+ The same report that uses the afore mentioned query is called each time; however, one time it's reporting for the Blue t-shirts and the other time for Red.

... instead of colours and t-shirts, Seth is using the status of the mail. Same thing... just different names.


One does not need to create a new report for each instance nor does one need to create a new query for each instance, that is what the parameter is for as mentioned in the tutorial.

Follow the tutorial. If you need further clarification please start a new thread referring back to this thread for context
Nov 2 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ROO | last post by:
Hi Everyone, I have a database table that have 4 field( C1, C2, M1, M2) on my form i have two combo box ComboC and ComboM C1 C2 M1 M2 1 ...
6
by: ProteusGak | last post by:
Hi, new membership and first post. I am working in VB 2005, windows forms and would like to know how to open form2 based on the user's selection from a combobox or listbox from say, form1. Thank...
1
by: edaddyj | last post by:
Hello, I have a db that tracks Jobs that our company does. Each job has a unique JobID. I have a report that groups all my jobs by JobStreetAddress. Since some jobs may be at the same address I...
5
by: jonosborne | last post by:
Hi, i have managed to filter a report based on selections made in a list box but am totally confused with a message box that appears everytime i run my report. Let me explain (i apologise for...
4
by: magmike | last post by:
I've created a report for the purpose of printing a one page summary of a record. Of course, when I created the report, it gives me a page on every record. Can I create a button to open that report...
1
by: rkm2 | last post by:
I currently have a form "UserSearchForm" which allows a user to select values from several different unbound combo boxes in the header section and press a search command which filters the list in the...
11
by: billa856 | last post by:
Hi, I have project in MS Access.In that I have one form in which there is one combobox .I want to know when I select an item from that combobox and click on submit button then it should open a...
5
by: Andrew Meador | last post by:
I have a form (Change Card List by Status) with a check box (cboNOT) and a list box (lstStatus). There is an Open Report button that opens a report (Report - Change Card List) which uses a query...
1
by: Emily Walshaw | last post by:
I'm sorry, I know this has been asked a million times, but am completely new to access and need idiot proof help. I have a database and I am struggling to get a field to update based on a combobox...
0
by: Moorthi chinna | last post by:
how to reload combobox in datagridview based on combobox selection in datagridview?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.