Solved

need report query without duplicate records

Posted on 2011-02-24
8
223 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
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 119

Expert Comment

by:Rey Obrero
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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now