Solved

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

Posted on 2011-03-25
9
571 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
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

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.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

777 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