?
Solved

query matches and not duplicates

Posted on 2011-02-11
12
Medium Priority
?
321 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 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 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