Solved

need report query without duplicate records

Posted on 2011-02-24
8
238 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2010 Only Including Numbers After Certain Limit 3 38
CISCO WIFI 6 58
MS Access vba Print  PDF First page only 16 22
Reoccurring Access Query 24 34
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

731 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