?
Solved

query matches and not duplicates

Posted on 2011-02-11
12
Medium Priority
?
316 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
[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
  • 7
  • 5
12 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

801 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