Return Multiple "between This And This" Records

TimTDP

Registered User.
Local time
Today, 21:32
Joined
Oct 24, 2008
Messages
213
I have the following data in tblProductBottle

ID, ProductBottleMinLength, ProductBottleMaxLength
1, 80, 90
2, 85, 90
3, 80, 85

I want to filter this data in a query based on criteria entered on a form. The form has the unbound field: Forms!frmFindProduct!intBottleDiameter

if 87 is entered into intBottleDiameter, only record 2 should be returned
if 81 is entered into intBottleDiameter, both records 1 & 3 should be returned
if 91 is entered into intBottleDiameter, no record should be returned

What should the query be to return the correct results?
 

Attachments

Why wouldn't record 1 be returned for 87? It's in the range. I would think:

ProductBottleMinLength <= Forms!frmFindProduct!intBottleDiameter AND ProductBottleMaxLength >= Forms!frmFindProduct!intBottleDiameter
 
Why wouldn't record 1 be returned for 87? It's in the range.
You are correct. My mistake!

I have tried what you suggest but it does not work. What you wrote is what I originally thought and really cannot understand why it does not work.
 
What is your SQL?
 
Last edited:
This works:

WHERE (((tblProductBottle.ProductBottleMinDiameter)<=[Forms]![Form1]![intBottleDiameter]) AND ((tblProductBottle.ProductBottleMaxDiameter)>=[Forms]![Form1]![intBottleDiameter]))
 

Users who are viewing this thread

Back
Top Bottom