Need Help with Filtering a Query/Report!!

E

Eka1618

Hello,

I am trying to filter a subReport with query for a RecordSource (qryResults).

Here is the SQL for my the query:

SELECT tblResults.Q_INC, tblResults.SAMPLE_NO, tblResults.FAILED_AT,
tblResults.P_F, tblResults.FAIL_LEVEL, tblResults.ON_OFF,
tblResults.FAIL_TORQ, tblResults.PASS_VALUE, tblResults.TENSION,
tblResults.NOTES, tblResults.OBSERVATIONS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.FAIL_TRQ_LEVEL, tblResults.SHROUD_OVAL, tblResults.L_ID,
tblResults.K_ID, tblResults.L_FAILURE_MODE, tblResults.K_FAILURE_MODE
FROM tblResults;


The master/Child link is: Q_INC

When the subform loads I want it to filter in two different conditions:

If Me.Parent.K_ID.Value = Null Then
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID
Me.FilterOn = True
Else
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID
Me.FilterOn = True
End If


This code does not work, and I do not know what to do. I have tried many
other methods, I'm not sure what to do...

If anyone has any suggestion please let me know. 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