I need some help in creating my query correctly. I have the following table:
tblPlans
PlanID PlanLevel MinAge MaxAge Points
A 1 0 18 5
A 2 0 18 11
A 3 0 18 20
: :
X 1 90 99 190
X 5 90 99 200
Based on the data from two fields on a form (txtAge, txtPoints), I have the following query:
Select PlanID, PlanLevel
From tblPlans
Where [txtAge] BETWEEN MinAge AND MaxAge
AND Points >= [txtPoints].
For the example:
txtAge = 15, txtPoints = 9, I would like my query to display PlanID A, PlanLevel 2, but not PlanId A/PlanLevel3 (only display the first PlanLevel within any PlanId that meets the criteria. The first in this instance is the one that is closest to the value of >= [txtPoints]).
One way that I can think of is to break out the points into a MinPoints and MaxPoints and use a query
Where [txtPoints] >= MinPoints and < MaxPoints.
Is there an alternate way of doing this?
Thank you
tblPlans
PlanID PlanLevel MinAge MaxAge Points
A 1 0 18 5
A 2 0 18 11
A 3 0 18 20
: :
X 1 90 99 190
X 5 90 99 200
Based on the data from two fields on a form (txtAge, txtPoints), I have the following query:
Select PlanID, PlanLevel
From tblPlans
Where [txtAge] BETWEEN MinAge AND MaxAge
AND Points >= [txtPoints].
For the example:
txtAge = 15, txtPoints = 9, I would like my query to display PlanID A, PlanLevel 2, but not PlanId A/PlanLevel3 (only display the first PlanLevel within any PlanId that meets the criteria. The first in this instance is the one that is closest to the value of >= [txtPoints]).
One way that I can think of is to break out the points into a MinPoints and MaxPoints and use a query
Where [txtPoints] >= MinPoints and < MaxPoints.
Is there an alternate way of doing this?
Thank you