View Single Post
  #3  
Old February 19th, 2007, 01:36 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default searching for similar records

Whoops. At least one Cut and paste error in there.

SELECT [SomeTable].BOM
, [SomeTable].[Time]
, [SomeTable].Price
, [SomeTable].Cables
, [SomeTable].Customer
, [SomeTable].PartNumber
FROM [SomeTable] INNER JOIN qPartMatch
ON [SomeTable].Customer = qPartMatch.Customer
AND [SomeTable].PartNumber = qPartMatch.PartNumber
WHERE [SomeTable].BOM
Between.9 * qPartMatch.BOM And 1.1 * qPartMatch.BOM
AND [SomeTable].Price
Between .9 * qPartMatch.Price and 1.1*qPartMatch.Price
AND [SomeTable].Cables
Between .9 qPartMatch.Cables and 1.1*qPartMatch.Cables
AND [SomeTable].[Time]
Between .9 qPartMatch.TimeToDoand 1.1*qPartMatch.TimeToDo

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"John Spencer" wrote in message
...
What type of fields are BOM, Time, Price, and cables?
What is your table Name?

I have to assume that the fields that you are matching plus or minus 10%
are numeric.

By the way Time is NOT a good field name, since it is a function to return
the current system time.

Save the following as qPartMatch
SELECT Customer, BOM, [Time] as TimeToDo, Price, Cables, PartNumber
FROM SomeTable
WHERE PartNumber = [What Part]

Use the above nested query in another query.

SELECT [SomeTable].BOM
, [SomeTable].[Time]
, [SomeTable].Price
, [SomeTable].Cables
, [SomeTable].Customer
, [SomeTable].PartNumber
FROM [SomeTable] INNER JOIN qPartMatch
ON [SomeTable].Customer = qPartMatch.Customer
AND [SomeTable].PartNumber = qPartMatch.PartNumber
WHERE [SomeTable].BOM
Between.9 * qPartMatch.BOM And 1.1 * qPartMatch.BOM
AND [SomeTable].Price
Between .9 * qPartMatch.Price and 1.1*qPartMatch.Price
AND [SomeTable].Cables
Between .9 qPartMatch.Cables and 1.1*qPartMatch.Cables
AND [SomeTable].Cables
Between .9 qPartMatch.TimeToDoand 1.1*qPartMatch.TimeToDo
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"Maax" wrote in message
...
Hello all, my database lists parts that have the following fields
(amongst
others),

BOM
TIME
PRICE
CABLES
CUSTOMER
PARTNUMBER

I would like to use a query that will return all records that are similar
to
a PARTNUMBER i enter. The query would search the records and return only
the
if the record has the following criteria;

CUSTOMER is same as CUSTOMER in the PARTNUMBER i enter.
BOM is within + or - 10% of the BOM on the PARTNUMBER i enter.
TIME is within + or - 10% of the TIME on the PARTNUMBER i enter.
PRICE is within + or - 10% of the PRICE on the PARTNUMBER i enter.
CABLES is within + or - 10% of the CABLES on the PARTNUMBER i enter.

I have managed in the past to enter each individual criteria (BOM,TIME
Etc.)
and return records but i am struggling to be able to enter a PARTNUMBER
and
have the records returned according to the above criteria.

I would very much appreciate any help on this query.

The query results will be used for a report.

many thanks