filter some records and permit all other related records

J

JohnLute

I have a complex query that I use in relation with a form in order to filter
out certain data. It works fine however it filters too well!

Basically, the query's record source is a table that functions as a Bill Of
Material. tblPKProfilesAssociations serves as the table.

I need to filter the fields txtFacilityID and LineID BUT also permit all
other related records to display.

For example.
txtProfileID 12345 is associated to 3 other txtProfileIDs:
100 Box
200 Box
300 Label

100 is used exclusively in txtFacilityID 04 on LineID 01 therefore related
records are created in tblPKProfilesAssocsFacIDs and
tblPKProfilesAssocsFacIDsLineIDs. 200 Box is used in ALL OTHER
txtFacilityID's and LineID's. 300 Label is used in ALL txtFacilityID's and
LineID's.

The query succeeds in filtering out a record according to txtFacilityID 04
and LineID 01 out however I need 300 Label to also display. Of course, it's
filtered out.

How can I filter txtFacilityIDs and LineIDs and permit all other related
records to display?

Here's the SQL of the query in question:

SELECT tblPKProfilesAssociations.ProfilesAssociations,
tblProfiles.Description, tblProfilesClassPK.Class,
tblPKProfilesAssociations.Comments, tblPKProfilesAssociations.txtProfileID,
tblPKProfilesAssocsFacIDs.txtFacilityID,
tblPKProfilesAssocsFacIDsLineIDs.LineID
FROM (((tblProfiles LEFT JOIN tblPKProfilesAssociations ON
tblProfiles.txtProfileID = tblPKProfilesAssociations.ProfilesAssociations)
INNER JOIN tblProfilesClassPK ON tblProfiles.txtProfileID =
tblProfilesClassPK.txtProfileID) LEFT JOIN tblPKProfilesAssocsFacIDs ON
tblPKProfilesAssociations.ProfilesAssociationsID =
tblPKProfilesAssocsFacIDs.ProfilesAssociationsID) LEFT JOIN
tblPKProfilesAssocsFacIDsLineIDs ON
tblPKProfilesAssocsFacIDs.ProfilesAssocsFacIDsID =
tblPKProfilesAssocsFacIDsLineIDs.ProfilesAssocsFacIDsID
WHERE (((tblProfilesClassPK.Class)="PK") AND
((tblPKProfilesAssocsFacIDs.txtFacilityID)=[Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDs])
AND
((tblPKProfilesAssocsFacIDsLineIDs.LineID)=[Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDsLineIDs]))
OR (((tblProfilesClassPK.Class)="PK") AND
((tblPKProfilesAssocsFacIDsLineIDs.LineID)=[Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDsLineIDs])
AND (([Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDs])
Is Null)) OR (((tblProfilesClassPK.Class)="PK") AND
((tblPKProfilesAssocsFacIDs.txtFacilityID)=[Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDs])
AND
(([Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDsLineIDs])
Is Null)) OR (((tblProfilesClassPK.Class)="PK") AND
(([Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDs]) Is
Null) AND
(([Forms]![frmQueryFGProcessingFacIDsLineIDs]![cbProfilesAssocsFacIDsLineIDs]) Is Null));

I know this is a rather intense question! Any help would be greatly
appreciated!

THANKS!!!
 

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