Solved

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

Posted on 2011-03-25
9
585 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
  • 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 47

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 47

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check a field in Access on a Timer 1 32
Frustrated by Access database design - what am I missing 3 35
Access Query: Text to Date 10 32
Access syntax 1 34
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

749 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