Solved

query matches and not duplicates

Posted on 2011-02-11
12
271 Views
Last Modified: 2012-05-11
code attached
this query displays serial numbers from TableCopy if match serial numbers from Table2-
 
problem: if serial number inputed 2 or more times-
Matches increase the number of records in Table2 and displays duplicate matches

is there a way it only matches one time- if same number inputed again- it does not display?

the data type is text- because- their will be letters in serial numbers-
thank you

SELECT Table2.[serial number] AS SerialNumber, TableCopy.[serial number] AS ScannedSerialNumber
FROM Table2 LEFT JOIN TableCopy ON Table2.[serial number]=TableCopy.[serial number];

Open in new window

0
Comment
Question by:davetough
  • 7
  • 5
12 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34871676
try this query

SELECT Table2.[serial number] AS SerialNumber, TC.[serial number] AS ScannedSerialNumber
FROM Table2 LEFT JOIN
(Select Distinct [serial number] From TableCopy) TC
 ON Table2.[serial number]=TC.[serial number];
0
 

Author Closing Comment

by:davetough
ID: 34871724
GREAT- thanks-
0
 

Author Comment

by:davetough
ID: 34872115
Hello Capricorn,
I wonder why this code works and then when I delete data in table and import new data into table- it tells me no current record when I try to run query
thank yo
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34872238
did you check if both tables have matching records
0
 

Author Comment

by:davetough
ID: 34872391
yes - am trying to recreate problem in sample database to show you- I create query- works fine- then i have delete all data button and it also closes database. then when I open the database- I have import button to import new data-
Thats when problem of no current record- and something at first about the second 'From' statement-
thank you
i scan in same number to match and it does not help
0
 

Author Comment

by:davetough
ID: 34872463
here is sample of problem- it gives error i first got-
everything is fine untill - I import new data into table
thank you
T-DB.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 119

Expert Comment

by:Rey Obrero
ID: 34872592
where is the data that you import?
0
 

Author Comment

by:davetough
ID: 34872639
I have it in an excel sheet on network and i have users enter data there and then hit a button in database to import it in-
Private Sub Command16_Click()
DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "Table2", "\\JRSHOP\AAB\Excel\database\Table1.xls", True, "Table1!"
DoCmd.OpenForm "frmImport"
Me.Form.Refresh
Exit_CmdImportExcel_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
End Sub
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34872663
where is the excel file?
0
 

Author Comment

by:davetough
ID: 34872746
on network next to database: here is copy
Table1.xls
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34872774
you are importing a blank excel file ?
0
 

Author Comment

by:davetough
ID: 34872838
sorry only numbers in serial numbers field get filled in sheet beforecoming into database
Table1.xls
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

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…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

743 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

14 Experts available now in Live!

Get 1:1 Help Now