Link to home
Start Free TrialLog in
Avatar of gbnorton
gbnortonFlag for United States of America

asked on

need report query without duplicate records

I have table TubeData with fields SerialNumber, DateReceived, Customer, Type, SalesOrder, PurchaseOrder, and Part Number.
Also have table CurrentLocation fields SerialNumber,DateMoved, Area, and PartNumber.

When the report is opened the user is prompted for SerialNumber and PartNumber.

The report opens and displays the field data from TubeData at the top of the page.  Then should list the records from the CurrentLocation table matching the SerialNumber and PartNumber.

In the attached db.  Open the Switchboard.  Under Reports select Move History for Tube by Serial Number.  
Enter the serial number 41049.  Part number PS463

There are 2 records in TubeData for SN 41049.  One received 8/9/10 and one received 12/17/10.
There are 12 records in CurrentLocation for SN 41049.

The report shows 24 records.  Duplicating each record in CurrentLocation for each record in TubeData.

I added a 3rd record to TubeData for 41049 and the report then shows 36 records.  Duplicating each record 3 times.

Here is the query used for the report:
SELECT TubeData.SerialNumber, TubeData.VmiPartNumber, TubeData.Date_Received, TubeData.Customer, TubeData.TubeType, TubeData.SalesOrder, [Current Location].SerialNumber, [Current Location].Area, [Current Location].[Date Moved], [Current Location].VmiPartNumber, TubeData.CustomerPO
FROM TubeData INNER JOIN [Current Location] ON TubeData.SerialNumber=[Current Location].SerialNumber
WHERE ((([Current Location].SerialNumber)=[Serial Number:]) AND ([Current Location].VmiPartNumber=[Part Number:] Or isnull([Current Location].VmiPartNumber)));

How can I eliminate the duplicate records in the report?
Thanks,
Brooks
EE-TTA.mdb
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

I'm not clear what you are expecting the result to be.

The query is working correctly, based on your description.
try adding a join in  [VmiPartNumber] , see what it give

FROM TubeData INNER JOIN [Current Location] ON (TubeData.VmiPartNumber = [Current Location].VmiPartNumber) AND (TubeData.SerialNumber = [Current Location].SerialNumber)
In Tube Data you have several instances of tubes with the same Serial Number but a different ID.  Then in Current Location you have in the example you gave 12 different dates on which a serial numbered tube was moved. It is normal behavior for the set of locations to be duplicated for every additional record for a given serial number in Tube Data.  Why do you have cases of two or more records for the same Serial Number.  I understand why you can have several parts with the same part number, but Serial Number?  

BTW, after opening the mdb using the Shift Key, on opening the Switchboard form (the only form) and following your instructions, nothing happens there are no controls on the form in which to enter a Serial Number and a Part Number.  Your instruction did not say which report to open.
Avatar of gbnorton

ASKER

peter57r:
There are 12 records in the CurrentLocation table with SerialNumber 41049 and VMIPartNumber PS463.  That is all I want to show up is those 12.  Currently 24 show up.

capricorn1:
I added the join and the result is the same.

GRayL:
The table holds records from 3 customers.  Sometimes they use the same serial numbers.  In this case they would have different part numbers.  The other case is for one customer a tube is returned for repair.  When it comes back it is added to the system again.

I uploaded the db again.  

Thanks,
Brooks
EE-TTA.mdb
ASKER CERTIFIED SOLUTION
Avatar of GRayL
GRayL
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works as Serial Number Query which the the query behind the Serial Number Move History Report

SELECT TubeData.SerialNumber, TubeData.VmiPartNumber, TubeData.Date_Received, TubeData.Customer, TubeData.TubeType, TubeData.SalesOrder, [Current Location].SerialNumber, [Current Location].Area, [Current Location].[Date Moved], [Current Location].VmiPartNumber, TubeData.CustomerPO
FROM TubeData INNER JOIN [Current Location] ON (TubeData.VmiPartNumber = [Current Location].VmiPartNumber) AND (TubeData.SerialNumber = [Current Location].SerialNumber)
WHERE TubeData.Date_Received = [EnterDate:] AND ((([Current Location].SerialNumber)=[Serial Number:]) AND (([Current Location].VmiPartNumber)=[Part Number:])) OR ((([Current Location].SerialNumber)=[Serial Number:]) AND ((IsNull([Current Location].[VmiPartNumber]))<>False));
That works thank you.
Thanks, glad to help.