Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find duplicates 1

Status
Not open for further replies.

JoanaSantos

Programmer
Feb 24, 2015
33
EU
Hi,

How can I find duplicates between two tables on access? VBA

table1: CC e Total
table2: CC e Total
 
Do you mean: record(s) in table1 that also is/are in table2 ?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Welcome to Tek-Tips. It helps if you provide more information related to your question.
Are the tables in Access? If so, this question might fit the forum701
A table typically has many fields. Are you looking for duplicates based on one or all fields?

Some examples of records might help us to help you.


Duane
Hook'D on Access
MS Access MVP
 
Oops, two tables, sorry.

Do you want to FIND the duplicates or REMOVE the duplicates?

Also, why maintain two tables. Why could they not be MERGED?

Multiple tables of the same structure are a pain to maintain, analyze and report.
 
and how can i merge the tables?

i'm sorry but i start working with access this week.

what is the best solution? for example, i have this two tables:


Month1 Month2
CC Total CC Total
1 2 1 2
2 3 3 1
3 1 4 5
4 5

For each CC the total is always the same.
CC 1 = always 2
CC 2 = always 3


i want to have something like this:
Month1 Month2
CC TotalMonth1 TotalMonth2
1 2 2
2 3 NULL
3 1 1
4 5 5

 
This is likely better expressed through a SQL query rather than VBA.

Something like the following:

[tt]SELECT Month1.CC, Month1.Total, Month2.Total
FROM Month1 LEFT JOIN Month2 ON Month1.CC = Month2.CC
UNION
SELECT Month2.CC, Month2.Total, Month1.Total
FROM Month2 LEFT JOIN Month1 ON Month2.CC = Month1.CC[/tt]
 
thanks. but there is a problem

the "total" from month2 don't appear on the right column
for example:

CC totalmotnh1 Totalmonth2
0
1
2
3
4
6
7
8
9
10

totalmotnh1
0
2
2
3
4
66
77
99
1010

Totalmonth2
(empty)

this column must have the total for month2
and the column totalmonth1 must have the total for month 1
 
Works fine here from the description you gave of your data and the tables. Of course, if your data is actually different from that description then all bets are off.

From your earlier description I have the following Access tables:

[tt][pre]
Month1
CC Total
1 2
2 3
3 4
4 5

Month2
CC Total
1 2
3 4
4 5[/pre][/tt]

Running the example query against these produces:
[tt][pre]
Query1
CC Month1.Total Month2.Total
1 2 2
2 3
3 4 4
4 5 5[/pre][/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top