Solved

Sub-Report Query SQL Based on Main Report Field????

Posted on 2011-03-25
9
591 Views
Last Modified: 2012-05-11
I have a main report with a sub-report for which I need the criteria in the sub based on the Employee ID and Date fields on the main report.  I've tried the following to no avail  on the criteria line of the sub report query.

=[Reports]![MyReportName]![TxtEMPLOYEE_ID]
=[Reports]![MyReportName]![TxtDATE]

I also tried using the OnFormat/OnPrint Events of the Employee Header of the report to pass the Employee and Date fields to a form and use those for criteria.  This did not work as well.

Any ideas will be appreciated.

Thanks,

ET Sherman
0
Comment
Question by:Eric Sherman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35218415
You don't need the equals sign.

But have you tried doing this with the Link fields ... Master/Child instead?

mx
0
 
LVL 19

Author Comment

by:Eric Sherman
ID: 35218467
Yes, also just tried with Linked fields .... for some reason same results (nothing) in the sub-report.  Although the Master table and the Child table will have multiple records for the same employee on the same date.

This report kind of combines two different process (or types of records) on one report by employee and date (different sections).

This is why I need the sub report based on the employee id and date from the main report.

ET
0
 
LVL 19

Author Comment

by:Eric Sherman
ID: 35218481
Seems like the SQL for the sub report is firing at the same the the SQL for the main report.  I can manually put the criteria in but I need it to be dynamic.

ET
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 35218505
I'm with MX, the easiest way to do this in a report is to use the Link Master/Link Child properties of the subform control.

NO POINTS PLEASE:
 
To do this, get rid of the WHERE clause (or at least the EmployeeID and Date portions of it) from the subforms RecordSource.  Then click on the subform in design view and in the Data tab of the Properties dialog, click on the "..." in either the "Link Master Field" or "Link Child Field" property box.  Select the fields that should match in the "Subform Field Linker" dialog box and click "OK".

Then you will have to go back to the current event of the main form, and get rid of any requery methods you were running against the subform.
0
 
LVL 75
ID: 35218559
Further note:

"When you specify more than one field or control name for these property settings, you must enter the same number of fields or controls for each property setting and separate the names with a semicolon (;).
"

mx
Capture1.gif
0
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 35218635
Are the date fields in the two tables all just dates, or is one based on date only, while the other includes Date and Time values?
0
 
LVL 19

Author Comment

by:Eric Sherman
ID: 35218654
Yep, thanks MX and fyed ... you are correct.  

Originally, I was not looking at the Link fields option because I got side-tracked a bit thinking that with multiple records in both tables I would somehow end up with duplicates on the report.  Therefore, I went straight for the query SQL criteria based on the Employee_ID and Date.  That's not the case though and the Link fields option is the proper approach to accomplish this task.

ET
0
 
LVL 19

Author Closing Comment

by:Eric Sherman
ID: 35218660
Thanks!!!
0
 
LVL 75
ID: 35218740
you are welcome ...

mx
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question