Solved

need report query without duplicate records

Posted on 2011-02-24
8
236 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:gbnorton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34971833
I'm not clear what you are expecting the result to be.

The query is working correctly, based on your description.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34972058
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)
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34972934
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gbnorton
ID: 34983447
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
0
 
LVL 44

Accepted Solution

by:
GRayL earned 500 total points
ID: 34988727
The way you have it written, you will have one complete set of TubeData/location records for each idential Serial Number in TubeData.  The only thing that discriminates between identical serial numbers is Date_Received.  Therefore you need to include the date as an additional parameter.  Add it to your WHERE clause

WHERE TubeData.DateReceived = [EnterDate:] AND <Your WHERE clause as you have it now>
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34988753
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));
0
 

Author Closing Comment

by:gbnorton
ID: 34998481
That works thank you.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35003274
Thanks, glad to help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question