473,378 Members | 1,492 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,378 software developers and data experts.

Limit Report by combo box selection

I have created a form in Access, similar to a switchboard in which I want to print reports, and I can do this. However, I want to print based on particular parameters; i.e. I have 2 combo boxes on the form and two comand buttons. Each combo box contains the same information; i.e. active, closed, cancelled, etc. but for a different report. I want to be able to run a report based on the parameter you click on within the combo box; i.e. if I select "Active", I want the report to only show "Active" projects. Can you help me? Thanks!
Dec 8 '06 #1
9 6839
NeoPa
32,556 Expert Mod 16PB
You don't need two ComboBoxes. One should do - just use it for each report.
Assuming :-
ComboBox = cboStatus
First command button = cmdReport1
Second command button = cmdReport2
Field in record to select by = Status
First report name = FirstReport
Second report name = SecondReport
Your code should be something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdReport1_Click()
  2.     Call DoReport("[FirstReport]")
  3. End Sub
  4.  
  5. Private Sub cmdReport2_Click()
  6.     Call DoReport("[SecondReport]")
  7. End Sub
  8.  
  9. Private Sub DoReport(strReport As String)
  10.     Dim strWhere As String
  11.  
  12.     strWhere = "[Status]='" & cboStatus & "'"
  13.     Call DoCmd.OpenReport(strReport, acViewPreview, ,strWhere)
  14. End Sub
Dec 8 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
"The title of this thread has been changed to make the problem clearer to experts and others searching for similar threads."

MODERATOR
Dec 9 '06 #3
Please let me know if you see anything wrong with my code. I am unable to view the reports when selecting an action from the "combo box"; i.e. active, closed and clicking on the cmd button for reports 1 or 2. Thank you for your help!

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdReport1_Click()                            'Name in Properties Box'
  2.  
  3.     Call DoReport("[Dashboard Reports]")               'Actual Name of Report'
  4.  
  5. End Sub
  6.  
  7. Private Sub cmdReport2_Click()                            'Name in Properties Box'
  8.  
  9.     Call DoReport("[Weekly Status Update]")           'Actual Name of Report'
  10.  
  11. End Sub
  12.  
  13. Private Sub DoReport(strReport As String)
  14.     Dim strWhere As String
  15.  
  16.     strWhere = "[Project Status]='" & cboProjectStatus & "'"    'Field in Table'
  17.     Call DoCmd.OpenReport(ReportName:=strReport, _
  18.                           View:=acViewPreview, _
  19.                           WhereCondition:=strWhere)
  20. End Sub
Dec 12 '06 #4
NeoPa
32,556 Expert Mod 16PB
I see no problems with your code.
What does happen (you've told us it doesn't work but nothing else)?
Any error message?
Does it go into debug mode?
Do you get an empty report?
Add the line
[code]Debug.Print strWhere[code]
into your code just after you set it up in the DoReport procedure then post the results in here please.
Dec 12 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Remove 'Call' from before DoCmd.OpenReport as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdReport1_Click()                            'Name in Properties Box'
  2.  
  3.    Call DoReport("[Dashboard Reports]")               'Actual Name of Report'
  4.  
  5. End Sub
  6.  
  7. Private Sub cmdReport2_Click()                            'Name in Properties Box'
  8.  
  9.    Call DoReport("[Weekly Status Update]")           'Actual Name of Report'
  10.  
  11. End Sub
  12.  
  13. Private Sub DoReport(strReport As String)
  14.     Dim strWhere As String
  15.  
  16.    strWhere = "[Project Status]='" & Me.cboProjectStatus & "'"    'Field in Table'
  17.    DoCmd.OpenReport(ReportName:=strReport, View:=acViewPreview, _
  18.    WhereCondition:=strWhere)
  19.  
  20. End Sub
  21.  
Mary
Dec 12 '06 #6
NeoPa
32,556 Expert Mod 16PB
Remove 'Call' from before DoCmd.OpenReport as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdReport1_Click()                            'Name in Properties Box'
  2.  
  3.    Call DoReport("[Dashboard Reports]")               'Actual Name of Report'
  4.  
  5. End Sub
  6.  
  7. Private Sub cmdReport2_Click()                            'Name in Properties Box'
  8.  
  9.    Call DoReport("[Weekly Status Update]")           'Actual Name of Report'
  10.  
  11. End Sub
  12.  
  13. Private Sub DoReport(strReport As String)
  14.     Dim strWhere As String
  15.  
  16.    strWhere = "[Project Status]='" & Me.cboProjectStatus & "'"    'Field in Table'
  17.    DoCmd.OpenReport(ReportName:=strReport, View:=acViewPreview, _
  18.    WhereCondition:=strWhere)
  19.  
  20. End Sub
  21.  
Mary
If you want to remove the 'Call' from a procedure call (I would certainly not recommend that) then you must remove the parentheses () from the parameter list.
Dec 12 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
If you want to remove the 'Call' from a procedure call (I would certainly not recommend that) then you must remove the parentheses () from the parameter list.
Sorry Ade

Misread the format and didn't look at the parameters, sorry.

Mary
Dec 12 '06 #8
NeoPa
32,556 Expert Mod 16PB
Sorry Ade

Misread the format and didn't look at the parameters, sorry.

Mary
No call for the Mea Culpa Mary. We're all trying to help here.
You of all people haven't anything to be sorry for.

-Ade.
Dec 12 '06 #9
NeoPa
32,556 Expert Mod 16PB
It's possible that OpenReport is one of those painful (MS provided) procedures that can't accept named parameters.
Well, what do you know, it is (Just tested it out).
Please revisit the updated post #2
Dec 12 '06 #10

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

Similar topics

3
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
1
by: Jack | last post by:
Hello All, Can anyone here suggest me a solution to solve my follwoing problem? 1) I got a .aspx page and on that page i got a combo box and a command button. Combo box displays records from the...
3
by: ducky | last post by:
I need help with opening a report when a button is clicked, but I only want to open the report with the Object I have chosen in the combo box. This is what i have so far: 'If 2 is selected open...
2
by: JweldonH | last post by:
My issue probably has a simple answer. I want to limit a populated combo box to items that are NOT in use in another table. I have a Table with a field that looks up values from another table via...
8
by: ShyGuy | last post by:
I have two combo boxes that get their values from two different tables. I want to limit the choices in the second combo box by what is selected in the first. I tried using SelText (code...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
5
by: Jason1983 | last post by:
Hi , I am having a Form that has 2 combo Boxes . The first one consists of particular Dates and Second one is the School Name. So when the user selects the Particular School the related data gets...
1
by: ikuyasu | last post by:
Hi, I am trying to create a report that takes a value from the field on a table as a group category. But The value on the report takes an id number (auto increment, and the first column)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.