Solved

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

Posted on 2011-03-25
9
550 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 - Access MVP) earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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)
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!!!
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
you are welcome ...

mx
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now