Applying a Filter to a Report

E

Eka1618

Hello,

I am trying to generate a report based on the following query: qryTestReports

The SQL for this query is:
SELECT tblRequest.REQUEST_NO, tblRequest.TITLE, tblRequest.NOTES,
tblQueue.Q_INC, tblQueue.QID, tblQueue.Q_YEAR, tblTest.TEST_TYPE,
tblTest.A_M, tblTest.WRENCH_NO, tblTest.INSTALL_TRQ, tblTest.DESCRIPTION,
tblTest.MIN_TORQ, tblTest.BOTH_DIRECTIONS, tblKey.K_ID, tblKey.K_PART_NO,
tblKey.K_EWO_NO, tblKey.K_SKID_NO, tblLock.L_ID, tblLock.LOCK_LUG,
tblLock.LUG_TOOL, tblLock.L_PART_NO, tblLock.L_EWO_NO, tblLock.L_SKID_NO
FROM (((tblRequest INNER JOIN tblTest ON tblRequest.REQUEST_NO =
tblTest.REQUEST_NO) INNER JOIN tblQueue ON tblTest.TEST_ID =
tblQueue.TEST_ID) INNER JOIN tblKey ON tblRequest.REQUEST_NO =
tblKey.REQUEST_NO) INNER JOIN tblLock ON tblRequest.REQUEST_NO =
tblLock.REQUEST_NO;


This Report has a subreport and in the sub report I need it to filter on two
different conditions. If the parent report's K_ID field is Null, then I want
my sub report to filter like this:

[L_ID]=Reports.[rptOffsetTestReport].L_ID

If the parent report's K_ID field is not null then I want my sub report to
filter like this:

[L_ID]=Reports.[rptOffsetTestReport].L_ID and [K_ID] =
Reports.[rptOffsetTestReport].[K_ID]

I cannot seem to figure out the point at which the report is filtered. I
have tried using the following code on onOpen, onLoad, onFilter:

If Me.Parent!K_ID.Value Is Null Then
Me.Filter = "[L_ID] = Reports.[rptStaticTestReport].[L_ID]"
Else
Me.Filter = "[L_ID] = Reports.[rptStaticTestReport].[L_ID]" And
"[K_ID] = Reports.[rptStaticTestReport].[K_ID]"
End If

I'm not that great with reports yet, so any help would be great. Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top