473,387 Members | 1,512 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.

Filter Report with 3 subreports via Combobox

294 256MB
Access 2007

I have a feeling there's probably 3-4 ways to do this (Macro, Me.Filter, Like " " , Link Child/Master fields, but I can't figure it out.

I have a Combobox (AstNameCbx) which I am trying to use to filter a report and the 3 subreports that lie within the main report. The fields for this combobox are EmployeeID, AstFirstName, AstLastName. Here is the Record Source for that Combobox:
Expand|Select|Wrap|Line Numbers
  1. SELECT [AssociateTbl].[EmployeeID], [AssociateTbl].[AstFirstName], [AssociateTbl].[AstLastName] FROM AssociateTbl ORDER BY [EmployeeID]; 


I've tried all of the code snippets I have found and none of them have worked. I have also tried putting this code in the 'Criteria' portion of the queries:
Expand|Select|Wrap|Line Numbers
  1. [Forms]![PlanFrm]![ReportWhatDatesFrm].[Form]![AstNameCbx]


For example, I tried (to no avail):
Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OpenReport "AnnualStmtRpt", acViewReport, , "AssociateTbl.EmployeeID =' " & [Form]![ReportWhatDatesFrm].[AstNameCbx] & " ' "
I think it would be easier to filter the main report on the EmployeeID value of the Combobox selection and link the child/master fields on the subreports.

Does anyone have any ideas or thoughts? If you need more information please let me know.
Jan 24 '14 #1

✓ answered by Rabbit

A few things wrong with the report.

1) You have detail data in the report header. The report header is only displayed once per report, hence it will only ever show one record. Detail data needs to go in the detail section of the report.

2) You have subreports that are linked to detail data in the page header. Page headers are only displayed once per page. If you have no detail data, then it will never display more than one page, and therefore you will only get one occurrence of your page header. Also, if you have multiple detail records on one page, you will only see the page header data for the first record on that page. The subreports also have to go in the detail section of the report.

3) Your main query is filtered to only one ID. You need to remove that filter.

26 3049
Rabbit
12,516 Expert Mod 8TB
You have an extra space after the first single quote in your criteria and an extra space before the closing single quote.
Jan 24 '14 #2
mcupito
294 256MB
Thanks, Rabbit. I got the Combobox to filter the report. Now for the dates, I tried to put
Expand|Select|Wrap|Line Numbers
  1. Between [Forms]![ReportWhatDatesFrm].[StartDateTxt] And [Forms]![ReportWhatDatesFrm].[EndDateTxt]
in the 'Criteria' for each query, and it keeps asking for the Parameter Value for those text boxes.

Any ideas on why the queries aren't able to find the dates I am entering in those text boxes?
Jan 24 '14 #3
Rabbit
12,516 Expert Mod 8TB
It is forum policy to answer only one question per thread. Please review this forum's posting guidelines and create a new thread for the new question.
Jan 24 '14 #4
mcupito
294 256MB
I take it back. The filter for EmployeeID isn't working. Instead of the VBA route, I chose to use the record source for the Combobox and open the Main report using the result from the selection.

However, it seems as though it isn't doing anything. The report opens with the same EmployeeID regardless of what I choose in the Combobox (AstNameCbx).. Any ideas?
Jan 24 '14 #5
Rabbit
12,516 Expert Mod 8TB
You will need to explain what you mean by "I chose to use the record source for the Combobox and open the Main report using the result from the selection."

Also, what is the SQL of the source for the combobox?
Jan 24 '14 #6
mcupito
294 256MB
SQL for the combobox:
Expand|Select|Wrap|Line Numbers
  1. SELECT [AssociateTbl].[EmployeeID], [AssociateTbl].[AstFirstName], [AssociateTbl].[AstLastName] FROM AssociateTbl ORDER BY [EmployeeID];
"I chose to use the record source for the Combobox and Open the Main report using the result from the selection"

-> When a user picks an Employee from the Combobox, I intended to use the EmployeeID of that person to filter the report. Through filtering the report on the EmployeeID, it then filters the subreports by Master/Child fields.

My issue is that the Combobox from the form is not passing the selection (EmployeeID, EmployeeName) to the report. The report keeps loading with the same Employee, regardless of what is selected in the Combobox.

I tried the VBA code rotue, and it keeps asking me to enter the EmployeeID as a Parameter Value:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "AnnualStmtRpt", acViewReport, , "EmployeeID = " & Me.AstNameCbx
Jan 24 '14 #7
Rabbit
12,516 Expert Mod 8TB
When it asks for a parameter entry, that usually means somethign is misspelled or doesn't exist.

What is the record source SQL for the report?

Check the following things:

1) That the combo box AstNameCbx is bound to the ID field and not another field.

2) That EmployeeID is exists and is spelled the same way in the record source for the report.

3) That the data types between the combo box value and the record source is the same.

4) That the filter string is outputting correctly.
Jan 24 '14 #8
mcupito
294 256MB
#2 is the issue. I do not have EmployeeID on the Main report. How would you suggest doing this?

As is, the main report opens with no record source or anything (it did return the same EmployeeID every run through, but I deleted it). I was merely trying to use the Combobox value to filter the Subreports and view the report that way, however it's obvious now that won't work because of #2 being nonexistent.

Should the main report just have a recordsource of the Associate table that lists the Associate's names, that way I can still link to the child/master fields, or should it be something else?

I am trying to list a report, with the 3 subreports, all filtered by EmployeeID. If I use a Combobox to perform this then great, if not, I would create all of the reports for each employee.

Any ideas? Thanks.
Jan 24 '14 #9
zmbd
5,501 Expert Mod 4TB
mcupito:

1) Recordsource:
Can be used for a CONTROL SOURCE in a form or control
Can be used for a ROW SOURCE in a combo/list box
Can be used for data manipulation in VBA or Query

These are not merely semantics, but precise vocabulary so that everyone can understand what is being done with what and where it is happening.

2) -filtering-
The following are several examples that cover a majority of situations and can be easily modified to suit your needs:
3) Rabbit has given you an answer to the original post.

4) Rabbit has asked you to start a new thread for a new question

[Z{Based on Rabbits subsequent post strike the following}]
[S]5) You have then attempted to ask yet a third question[/S]

Please start a new thread. You may insert a link back to this thread for context should you feel the need.
Jan 24 '14 #10
Rabbit
12,516 Expert Mod 8TB
@zmbd, I don't think this is a third issue. It's that we have discovered the root cause of the first issue that the OP thought was resolved but wasn't.

@mcupito, your main report's record source should be something that includes the unique employee ids from your data. This way you would be able to use the master/child to filter the subreport and you can filter the main report through the existing code.
Jan 24 '14 #11
mcupito
294 256MB
Rabbit, I used a query that simply has EmployeeID, FirstName and LastName fields as the record source for the report. I linked the subreports to the report via EmployeeID Child/Master fields. It still is not filtering the subreports, and I can't select other employees reports also (the record selector at the bottom - which would be essential for year -end reporting)

Any ideas?
Jan 27 '14 #12
Rabbit
12,516 Expert Mod 8TB
We would need more detail, i.e. the record sources for the main report and sub reports, the code that opens the report, any other relevant code or properties, and an explanation of what you mean when you say: "It still is not filtering the subreports, and I can't select other employees reports also (the record selector at the bottom - which would be essential for year -end reporting)"
Jan 27 '14 #13
mcupito
294 256MB
The Main report is to contain 3 subreports, all should be filtered by EmployeeID. I.E If there are 10 employees, there should be 10 main reports with 30 subreports.

As is, I have the Recourd Source for the Main report being:
Expand|Select|Wrap|Line Numbers
  1. SELECT AssociateTbl.EmployeeID, AssociateTbl.AstFirstName, AssociateTbl.AstLastName
  2. FROM AssociateTbl
  3. ORDER BY AssociateTbl.EmployeeID;
  4.  
Using the Link Master/Child fields, I plan on filtering the subreports by EmployeeID from the above Recourd Source. (This has not worked for me yet.)

The Sub Report Record Sources are as follows:
Award Subreport
Expand|Select|Wrap|Line Numbers
  1.  SELECT AwardTbl.EmployeeID, AwardTbl.PlanID, PlanTbl.PlanDesc, AwardTbl.AwardDate, AwardTbl.AwardUnits, AwardTbl.AwardNAV, NAV_Tbl.NetAssetValue, [AwardTbl]![AwardUnits]*[NAV_Tbl]![NetAssetValue] AS CurrentValue, AssociateTbl.AstFirstName, AssociateTbl.AstLastName
  2. FROM (PlanTbl INNER JOIN (NAV_Tbl INNER JOIN AwardTbl ON NAV_Tbl.NAV_Date = AwardTbl.AwardNAV) ON PlanTbl.PlanID = AwardTbl.PlanID) INNER JOIN AssociateTbl ON AwardTbl.EmployeeID = AssociateTbl.EmployeeID
  3. GROUP BY AwardTbl.EmployeeID, AwardTbl.PlanID, PlanTbl.PlanDesc, AwardTbl.AwardDate, AwardTbl.AwardUnits, AwardTbl.AwardNAV, NAV_Tbl.NetAssetValue, [AwardTbl]![AwardUnits]*[NAV_Tbl]![NetAssetValue], AssociateTbl.AstFirstName, AssociateTbl.AstLastName
  4. HAVING (((AwardTbl.AwardDate) Between [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![StartDateTxt] And [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![EndDateTxt]));
Forfeiture Subreport
Expand|Select|Wrap|Line Numbers
  1. SELECT AssociateTbl.EmployeeID, AwardTbl.ForfeitDate, AwardTbl.ForfeitedUnits, PlanTbl.PlanDesc, PlanTbl.PlanID, NAV_Tbl.NetAssetValue, [AwardTbl]![ForfeitedUnits]*[NAV_Tbl]![NetAssetValue] AS [Current Value], AssociateTbl.AstFirstName, AssociateTbl.AstLastName
  2. FROM NAV_Tbl INNER JOIN ((AssociateTbl INNER JOIN AwardTbl ON AssociateTbl.EmployeeID = AwardTbl.EmployeeID) INNER JOIN PlanTbl ON AwardTbl.PlanID = PlanTbl.PlanID) ON NAV_Tbl.NAV_Date = AwardTbl.ForfeitNAV
  3. GROUP BY AssociateTbl.EmployeeID, AwardTbl.ForfeitDate, AwardTbl.ForfeitedUnits, PlanTbl.PlanDesc, PlanTbl.PlanID, NAV_Tbl.NetAssetValue, [AwardTbl]![ForfeitedUnits]*[NAV_Tbl]![NetAssetValue], AssociateTbl.AstFirstName, AssociateTbl.AstLastName
  4. HAVING (((AwardTbl.ForfeitDate) Between [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![StartDateTxt] And [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![EndDateTxt]));
  5.  
Payout Subreport
Expand|Select|Wrap|Line Numbers
  1. SELECT AssociateTbl.EmployeeID, PlanTbl.PlanDesc, PayoutTbl.PytDate, PayoutTbl.PytUnits, PayoutTbl.PytNAV, PlanTbl.PlanID, [PayoutTbl]![PytUnits]*[NAV_Tbl]![NetAssetValue] AS [Value], AssociateTbl.AstFirstName, AssociateTbl.AstLastName, NAV_Tbl.NetAssetValue
  2. FROM NAV_Tbl INNER JOIN ((AssociateTbl INNER JOIN (PayoutTbl INNER JOIN AwardTbl ON PayoutTbl.AwardID = AwardTbl.AwardID) ON AssociateTbl.EmployeeID = AwardTbl.EmployeeID) INNER JOIN PlanTbl ON AwardTbl.PlanID = PlanTbl.PlanID) ON NAV_Tbl.NAV_Date = PayoutTbl.PytNAV
  3. GROUP BY AssociateTbl.EmployeeID, PlanTbl.PlanDesc, PayoutTbl.PytDate, PayoutTbl.PytUnits, PayoutTbl.PytNAV, PlanTbl.PlanID, [PayoutTbl]![PytUnits]*[NAV_Tbl]![NetAssetValue], AssociateTbl.AstFirstName, AssociateTbl.AstLastName, NAV_Tbl.NetAssetValue
  4. HAVING (((PayoutTbl.PytDate) Between [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![StartDateTxt] And [Forms]![PlanFrm]![ReportSelectSbfrm].[Form]![EndDateTxt]));
  5.  
When I open the Main report, the subreports show up, however there is no data. I would like the data that is retrieved from each of the 3 subreports to be filtered for only the EmployeeID on each Main report.

That being said, I am expecting to have multiple reports (1 for each employee) which I have not been able to retrieve also. Hence my reference to not being able to view multiple reports.

It's almost as if the Main report / Subreports aren't communicating.

The code that opens the report is:
Expand|Select|Wrap|Line Numbers
  1.         Case 14
  2.             DoCmd.OpenReport "AnnualStmtRpt", acViewReport
Note: I am no longer trying to use a Combobox to filter which employee I want to see the reports for. I want to see the reports for every employee, however, 1 employee per report.

I hope this helps!
Thanks.
Jan 27 '14 #14
Rabbit
12,516 Expert Mod 8TB
I recreated the basic structure of your tables and reports and have no problem getting data to show up. This most likely means that your queries don't return any data or that one of your settings is off. I would check each of the following:

1) That the parent and child fields are linked correctly.

2) That the source of each query is returning the correct data.

3) That each subreport opens by itself with the correct data populated.
Jan 27 '14 #15
mcupito
294 256MB
It seems to be returning SOME data, however I still can't get the report for every employee. Only the first employee if sorting by EmployeeID ASC is returned, so I can't test if it is truly working or not.

Any ideas on what that could be?
Jan 27 '14 #16
Rabbit
12,516 Expert Mod 8TB
Only the three points above come to mind. Can you zip and attach the database to the thread in a 2007 or earlier format?
Jan 27 '14 #17
mcupito
294 256MB
Unfortunately, no, because of persons addresses, names and account information. (It would take extremely long to configure dummy data for this particular scenario.)

Is there any information or screen shots I could post that would help you?
Jan 27 '14 #18
mcupito
294 256MB
Here's an image of the Main report returning data. I just need a report for every Employee, and that's what I am having trouble doing. I hope that makes sense.

Attached Images
File Type: jpg AnnualRpt.jpg (52.4 KB, 1021 views)
Jan 27 '14 #19
Rabbit
12,516 Expert Mod 8TB
Can you just blank out all the sensitive data?
Jan 27 '14 #20
mcupito
294 256MB
It would be pretty difficult, and it utilizes a backend. Sorry, I wish I could because it's bothering me.
Jan 27 '14 #21
mcupito
294 256MB
Okay, it should be pretty harmless. I included a copy and pasted in the necessary items.

The PW is OH!@
Attached Files
File Type: zip DatabaseCopy.zip (2.62 MB, 113 views)
Jan 27 '14 #22
Rabbit
12,516 Expert Mod 8TB
A few things wrong with the report.

1) You have detail data in the report header. The report header is only displayed once per report, hence it will only ever show one record. Detail data needs to go in the detail section of the report.

2) You have subreports that are linked to detail data in the page header. Page headers are only displayed once per page. If you have no detail data, then it will never display more than one page, and therefore you will only get one occurrence of your page header. Also, if you have multiple detail records on one page, you will only see the page header data for the first record on that page. The subreports also have to go in the detail section of the report.

3) Your main query is filtered to only one ID. You need to remove that filter.
Jan 27 '14 #23
mcupito
294 256MB
#3 was for testing purposes, sorry about that.

Thank you, I did not know that about the Detail section.

Is there a way to create a new main report for each EmployeeID?
As is, it just lists all of the "Detail" sections of the report over and over again, without creating their own report.
Jan 27 '14 #24
Rabbit
12,516 Expert Mod 8TB
If you mean you want to open multiple instances of the report, you can't do that unless you want to make a bunch of copies of the reports in Access and I highly suggest you do not do that.

If you mean you want each detail record on its own page, then put in a page break.
Jan 27 '14 #25
mcupito
294 256MB
Thanks, Rabbit. You've been a great help.
Jan 28 '14 #26
Rabbit
12,516 Expert Mod 8TB
No problem, good luck with the rest of your project.
Jan 28 '14 #27

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

Similar topics

3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
0
by: KartoffelKiffer | last post by:
Hello, i have to do a little Crystal Report task, where i need help. I have a mainreport in which are some subreports. The size of the subreports can vary so the subreport which could be bigger...
2
by: olle | last post by:
hi everyone. I have this code to apply the filter on a form to a report. In Access97 it worked fine but when I converted it to Access2000 the report shows all records in the table. What has...
94
by: mlcampeau | last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries. MY - JobVacancyJobs SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum,...
1
by: Cara Murphy | last post by:
Hi There! Hoping you are able to help me with a filtering scenario: I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which...
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...
2
by: kfboren | last post by:
I am wondering if someone can help me. I have created 10 tables, 10 queries for the tables and 10 reports from the quearies. The creteria for the queries is the field named "month". I have created...
2
by: jim190 | last post by:
I am relatively new to using VBA and am have been trying for two days to pass a user entered value to my report for filtering when opened. I have the following subroutine in the open event of my...
5
by: DAHMB | last post by:
I have a report that I filter on the fly the following is my code, it worked before but now I added a checkbox to the filter process. I don't know how to write the code properly for the checkbox...
0
by: LBinGA | last post by:
Hello! I am using Access 2010 and I have an Unbound Form (FrmFilter) that filters a report by (up to) 7 criteria using the code below, which works beautifully. I would like to add 2 additional...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.