473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select from two combo boxes on form to run report

15 New Member
Hi All,

I have been reading some of the threads in your forum and decided to join and post my question. Hopefully it won't be too lengthy.

I have created an Unbound Form called paramform2. This form contains two combo boxes, a text box for the start date, a text box for the end date and a command button that runs the report.

The first combo box is named FindMgr. The row source of this box is set to: SELECT"All" As MgrName FROM tblMain UNION SELECT MgrName FROM tblMain ORDER BY MgrName. Column Count and Bound Column are both set to 1. The After Update event is:

Me!FindMgr.Requ ery
Me!FindMgr.SetF ocus

The second combo box is named: FindDBS. The row source of this box is set to: SELECT DISTINCT strDBS FROM tblMain WHERE MGRName=Forms!P aramForm2.FindM gr ORDER BY strDBS; Column Count and Bound column are both set to 1.

The criteria in the query for both boxes are: [Forms]![ParamForm2].[FindMgr] and [Forms]![ParamForm2].[FindDBS]

When I select a one manager name and one employee name and run the report, I get a report for all of the employees listed under that Manager.

There are two things I need to be able to do:

1. Select one manager name and one employee name and have the report run just for that manager and that one employee.

2. Select a manager name and have a report run for all of the employees under that manager.

Is there a way to do this? Any help would be greatly appreciated.

Thank you.
Jul 17 '09 #1
10 2504
ChipR
1,287 Recognized Expert Top Contributor
What's the SQL for your query look like?
Is DBS = employee name? It looks like your After Update event should requery the FindDBS box rather than the FindMgr box.
Jul 20 '09 #2
BeaBea
15 New Member
Hi Chip,

Thank you for your reply.

The SQL view of my query is:

SELECT qryMaster.MgrNa me, qryMaster.strSS N, qryMaster.strCl aimantName, qryMaster.strPr oduct, qryMaster.strTy peofClaim, qryMaster.ysnAp proved, qryMaster.ysnNo nComp, qryMaster.[curr$$Paid], qryMaster.dtmDe cisionDate, tblDBS.DBSName
FROM (qryMaster INNER JOIN tblDBS ON qryMaster.strDB S = tblDBS.DBSName) INNER JOIN tblManagers ON (qryMaster.MgrN ame = tblManagers.Mgr Name) AND (tblDBS.cmbMana ger = tblManagers.Mgr Name)
WHERE (((qryMaster.Mg rName)=[Forms]![ParamForm2].[FindMgr]) AND ((tblDBS.DBSNam e)=[Forms]![ParamForm2].[FindDBS]) AND (([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm2]![StartDate] And [Forms]![ParamForm2]![EndDate])) OR (((qryMaster.Mg rName)=[Forms]![ParamForm2].[FindMgr]) AND (([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm2]![StartDate] And [Forms]![ParamForm2]![EndDate])) OR ((([Forms]![ParamForm2].[FindMgr])="All"));

Yes,DBS = employee name. I will change the After Update event.

Please let me know if there is anything else I can supply that might help us find a solution for what I need to accomplish.
Jul 20 '09 #3
ChipR
1,287 Recognized Expert Top Contributor
I think we can see, with the query spaced out, that even when a FindDBS is specified, the OR from line 16 to 26 is going to match records that don't match the FindDBS. We'll need to rework the logic for the query. I hope to have time to revisit this later today. Possibly add in something around line 25 to make sure that no DBS is specified with an AND.
Expand|Select|Wrap|Line Numbers
  1. WHERE
  2. (
  3.   (
  4.     (qryMaster.MgrName)=[Forms]![ParamForm2].[FindMgr]
  5.   )
  6.   AND
  7.   ( 
  8.     (tblDBS.DBSName)=[Forms]![ParamForm2].[FindDBS]
  9.   )
  10.   AND
  11.   (
  12.     ([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm2]![StartDate] 
  13.     And [Forms]![ParamForm2]![EndDate]
  14.   )
  15. )
  16. OR
  17. (
  18.   (
  19.     (qryMaster.MgrName)=[Forms]![ParamForm2].[FindMgr]
  20.   )
  21.   AND
  22.   (
  23.     ([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm2]![StartDate]
  24.     And [Forms]![ParamForm2]![EndDate]
  25.   )
  26. )
  27. OR 
  28. (
  29.   (
  30.     ([Forms]![ParamForm2].[FindMgr])="All"
  31.   )
  32. )
Jul 20 '09 #4
BeaBea
15 New Member
Hi Chip,

I changed the SQL a little bit and was able to run a report based on 1 Manager Name and 1 Employee Name. Here is the updated SQL.

SELECT qryMaster.MgrNa me, qryMaster.strSS N, qryMaster.strCl aimantName, qryMaster.strPr oduct, qryMaster.strTy peofClaim, qryMaster.ysnAp proved, qryMaster.ysnNo nComp, qryMaster.[curr$$Paid], qryMaster.dtmDe cisionDate, tblDBS.DBSName, tblMain.dtmDeci sionDate AS Expr1, Forms!ParamForm 3.FindMgr AS Expr2
FROM (qryMaster INNER JOIN tblDBS ON qryMaster.strDB S = tblDBS.DBSName) INNER JOIN tblManagers ON (tblDBS.cmbMana ger = tblManagers.Mgr Name) AND (qryMaster.MgrN ame = tblManagers.Mgr Name)
WHERE (((qryMaster.Mg rName)=[Forms]![ParamForm3].[FindMgr]) AND ((tblDBS.DBSNam e)=[Forms]![ParamForm3].[FindDBS]) AND (([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm3]![StartDate] And [Forms]![ParamForm3]![EndDate])) OR ((([Forms]![ParamForm3].[FindMgr])="All"));

Still working on being able to select a Manager Name and have a report run for all employees under that Manager as well.

Thank you,
Jul 22 '09 #5
ChipR
1,287 Recognized Expert Top Contributor
How do you want the user to choose all employees under one manager? Do you want to use "all" like in the FindMgr, or just leave the FindDBS combo blank? Something like:
Expand|Select|Wrap|Line Numbers
  1. WHERE 
  2.   ([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm3]![StartDate] 
  3.   And [Forms]![ParamForm3]![EndDate] 
  4. )
  5. AND
  6. (
  7.   ([Forms]![ParamForm3].[FindMgr])="All" 
  8.   OR
  9.   (
  10.     (qryMaster.MgrName)=[Forms]![ParamForm3].[FindMgr] 
  11.     AND  
  12.     (
  13.       [Forms]![ParamForm3].[FindDBS]="All"   'or ""
  14.       OR
  15.       (tblDBS.DBSName)=[Forms]![ParamForm3].[FindDBS]
  16.     )
  17.   )
  18. )
Jul 22 '09 #6
BeaBea
15 New Member
Hi Chip,

I think the best way would be to leave the FindDBS field blank.

Thank you.
Jul 22 '09 #7
ChipR
1,287 Recognized Expert Top Contributor
In that case, the code in the previous post should work, with line 14 ending with [FindDBS]=""
Jul 22 '09 #8
BeaBea
15 New Member
Hi Chip,

I so very much appreciate all of your help. I am getting closer to finishing this database.

I typed the code you gave me. But when I tried running a report by selecting the Managers name and leaving the DBS name blank it did not return any records. This is what I have for my SQL now.

SELECT qryMaster.MgrNa me, qryMaster.strSS N, qryMaster.strCl aimantName, qryMaster.strPr oduct, qryMaster.strTy peofClaim, qryMaster.ysnAp proved, qryMaster.ysnNo nComp, qryMaster.[curr$$Paid], qryMaster.dtmDe cisionDate, tblDBS.DBSName, tblMain.dtmDeci sionDate AS Expr1, Forms!ParamForm 3.FindMgr AS Expr2
FROM (qryMaster INNER JOIN tblDBS ON qryMaster.strDB S=tblDBS.DBSNam e) INNER JOIN tblManagers ON (tblDBS.cmbMana ger=tblManagers .MgrName) AND (qryMaster.MgrN ame=tblManagers .MgrName)
WHERE (([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm3]![StartDate] AND [Forms]![ParamForm3]![EndDate]) AND (([Forms]![ParamForm3].[FindMgr])="All" OR ((qryMaster.Mgr Name)=[Forms]![ParamForm3].[FindMgr] AND ([Forms]![ParamForm3].[FindDBS]="" OR (tblDBS.DBSName )=[Forms]![ParamForm3].[FindDBS])));

Thank you,
Jul 22 '09 #9
ChipR
1,287 Recognized Expert Top Contributor
Sorry, it seems a blank box is not the same as "". It's considered Null, so (hopefully) we can check for that. Try this out:
Expand|Select|Wrap|Line Numbers
  1. WHERE
  2. (
  3.   ([tblMain].[dtmDecisionDate]) Between [forms]![ParamForm3]![StartDate] 
  4.   AND [Forms]![ParamForm3]![EndDate]
  5. )
  6. AND
  7. (
  8.   ([Forms]![ParamForm3].[FindMgr])="All" 
  9.   OR
  10.   (
  11.     (qryMaster.MgrName)=[Forms]![ParamForm3].[FindMgr] 
  12.     AND 
  13.     (
  14.       [Forms]![ParamForm3].[FindDBS] IS NULL
  15.       OR
  16.       (tblDBS.DBSName)=[Forms]![ParamForm3].[FindDBS]
  17.     )
  18.   )
  19. );
Glad you're getting closer.
Jul 22 '09 #10

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

Similar topics

1
2375
by: hawk | last post by:
I am creating a series of custom reports, whose parameters are specified through combo boxes in a form, which then generates a custom report based on a series of calculation queries. My problem is this...at the top of the report I've inserted several text boxes which link to the combo boxes on the entry form, and are supposed to show which parameters a particular report is being generated from. On the screen, everything looks great and...
5
2383
by: Dalan | last post by:
I have been searching the archives in an effort to discover how to derive a dual use of a single combo box - so far no go. I found the piece below which pretty much represents the usage. To summarize: The cboKeyword box on the frmCustomer looks up Keywords from a separate table that have just a list of keywords and a KeyID number. The bound column is tied to the autonumber and is saved in the frmCustomer table. The keywords appear in the...
3
11072
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 as dates) in a text box. This procedure works fine. However, I also need to enter data from a combo box and I cannot get this to work. On my form I've created an unbound combo box named "Name". In the query bound to the report I've entered the...
3
2273
by: Stig | last post by:
Hi, Any help on this one will be greatly appreciated as I have spent too long banging my head against the screen trying to get it sorted. Basically I would like to have a select all records option in a combo box that is used in an unbound form for my report parameter. I have tried to explain it in further detail below: - In my DB I have numerous forms are used to input details into a table (TblMasterTable).
4
1978
by: Miguel | last post by:
I have synchronized combo boxes linking Account Type with Customer Names based on the template that Microsoft has in one of its samples databases. There are the appropriate relationships between the Account Type Table and the Customer Name Table based on the ID field, so it is the ID field which is stored in the main table. However, in the form, the Account Type and Customer Name are displayed because the column width property has been...
5
3702
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and just choose the appropriate criterias from the combo boxes to get the results. I also want the query to run even if there is not a value in all the combo boxes ie., i want just all males with income level of over $100,000...Any insights or help...
2
2041
by: mumbaimacro | last post by:
hi i have two combo boxes in a form with values from a table. i need a report to be opened by a button from the form ,The Report should show the values selected in the combo boxes in the form and also i am going to show some other values from tables in the report with that. example: form view: month: jan --> selected from combobox year : 2006 --> selected from combobox
1
3060
by: brsawvel | last post by:
Hello, I have a form with text/combo boxes that draws from a query and sends records to a report. The query has the following code in the criteria block of some of the columns: !! This code tells the query to select only those records that match what was entered or selected in the pertinent text/combo box in the "report" form. So the SQL appears as follows: SELECT tbl.fld1, tbl1.fld2, tbl1.fld3,...
12
4045
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just not several, to report using this code i found - Private Sub cmdPreview_Click()
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.