?
Solved

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

Posted on 2011-03-25
9
Medium Priority
?
592 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 48

Expert Comment

by:Dale Fye
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
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 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