MS Access switch query not ending after first condition is met

261 views Asked by At

I am trying to run a select query in MS Access whose values being evaluated meet more than one criteria (ie: date ranges). The results for the below query include duplicates because the statement keeps evaluating even after the first statement is met. What am I doing wrong in this statement, or is this not the correct statement to use? I have tried using iif statements but they also have the same result.

Primary Rec: Switch(
  [tblData].[Beg Dt] >= [qryPrimaryRt].[Beg Dt]
  And [tblData].[End Dt] <= [qryPrimaryRt].[End Dt]
, [qryPrimaryRt].[Primary Rec]
, [qryRtByMaxDays].[Primary Rec] Is Not Null
  And (
    [tblData].[Beg Dt] < [qryPrimaryRt].[Beg Dt]
    Or [tblData].[End Dt] < [qryPrimaryRt].[End Dt]
  )
, [qryRtByMaxDays].[Primary Rec]
, [tblData].[TOC] = 117 Or [tblData].[TOC] = 297
, [tblData].[Rec Loc Name]
)
0

There are 0 answers