Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ignore conditions in a query

Status
Not open for further replies.

diwin

Technical User
Joined
Nov 29, 2002
Messages
218
Location
CA
Can I put a condition on these conditions???

The red conditions below only apply when there is 1 or more records in the associated table ( tblPickYearSeason or tblPickBugStage). If either or both of the named tables is/are empty, the condition(s) should be ignored and allow all records to be tested against the remaining condition(s). Can I do that?

Code:
SELECT DISTINCT tblPointInfo.MainPointID AS ID, tblPointInfo.Point, tblPointInfo.PointType, tblSiteInfo.SiteID, tblPointInfo.YearID, tblPointInfo.SeasonID, tblBugInfo.BugID, tblBugLifeStageInfo.f_BugStageID
FROM ((tblBugLifeStageInfo 
INNER JOIN tblBugInfo ON tblBugLifeStageInfo.f_Bug = tblBugInfo.ID) 
INNER JOIN tblPointInfo ON tblBugInfo.f_Point = tblPointInfo.ID) 
INNER JOIN tblSiteInfo ON tblPointInfo.f_SiteID = tblSiteInfo.ID
WHERE (((tblSiteInfo.SiteID)=[Forms]![frmViewInfo].[txtTest]) 
AND [red]((tblPointInfo.YearID) In (SELECT f_YearID FROM tblPickYearSeason ))[/red] 
AND [red]((tblPointInfo.SeasonID) In (SELECT f_SeasonID FROM tblPickYearSeason ))[/red] 
AND [red]((tblBugInfo.BugID) In (SELECT f_BugID FROM tblPickBugStage ))[/red] 
AND [red]((tblBugLifeStageInfo.f_BugStageID) In (SELECT f_StageID FROM tblPickBugStage ))[/red]);

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
Try:

Code:
WHERE tblSiteInfo.SiteID=[Forms]![frmViewInfo].[txtTest]
AND (tblPointInfo.YearID In 
      (SELECT f_YearID 
       FROM tblPickYearSeason) OR Dcount("*","tblPickYearSeason")=0)
AND (tblPointInfo.SeasonID In 
      (SELECT f_SeasonID 
       FROM tblPickYearSeason) OR Dcount("*","tblPickYearSeason")=0)
AND (tblBugInfo.BugID In 
      (SELECT f_BugID 
       FROM tblPickBugStage) OR Dcount("*","tblPickBugStage")=0)
AND  (tblBugLifeStageInfo.f_BugStageID In 
      (SELECT f_StageID 
       FROM tblPickBugStage)  OR Dcount("*","tblPickBugStage")=0)



(It all sounds pretty interesting)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top