hi, every one
for delete duplicated rows can any one up to us an example to see that
because i`m beginning to ms access
and i have a problem about that
thank you for all
abo mroan
12 2896 NeoPa 32,579
Recognized Expert Moderator MVP
When posting your question it is necessary to put it in its own thread. Hijacking somebody else's ( Delete Duplicate records) is not acceptable. It is acceptable to post a link if you think it's relevant though. I have split it away for you (and included a link across), but please remember in future.
NeoPa 32,579
Recognized Expert Moderator MVP
If you had read the previous thread you would have seen that posts #9 & #10 have examples of code for this job. Unfortunately, as you haven't explained what you need other than very generally, I cannot say how well suited either is for your needs. In case it helps though (and for anyone finding this in a search) I will include my code from Post #10 of Delete Duplicate records.
This code assumes a table in the local db but it can be tweaked or enhanced.
For instance, if the one to be kept must have the lowest Primary Key value then it could be changed to do that. - 'DelDups Removes duplicate records in strTable matched on strField
-
Public Sub DelDups(strTable As String, strField As String)
-
Dim strSQL As String, varLastVal As Variant
-
-
'Recordset must be full table but sorted by the field we're checking
-
strSQL = "SELECT * FROM [" & strTable & "] ORDER BY [" & strField & "]"
-
With CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
-
varLastVal = Null
-
'For each record, check against previous value in strField
-
'If same then this is a duplicate so can be removed
-
Do Until .EOF
-
If .Fields(strField) = varLastVal Then
-
Call .Delete
-
Else
-
varLastVal = .Fields(strField)
-
End If
-
Call .MoveNext
-
Loop
-
'Ending the 'With' releases the Recordset
-
End With
-
End Sub
Hope it helps.
Mr NeoPa
it`s a perfect code thank you very much
but what the condition if there 2 fields
i try it and it work as well - 'DelDups Removes duplicate records in strTable matched on strField
-
Public Function DelDups(strTable As String, strField As String, strField1 As String)
-
Dim strSQL As String, varLastVal As Variant, varLastVal1 As Variant
-
-
'Recordset must be full table but sorted by the field we're checking
-
strSQL = "SELECT * FROM [" & strTable & "] ORDER BY [" & strField & "] , [" & strField1 & "]"
-
With CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
-
varLastVal = Null
-
varLastVal1 = Null
-
-
'For each record, check against previous value in strField
-
'If same then this is a duplicate so can be removed
-
Do Until .EOF
-
If .Fields(strField) = varLastVal And .Fields(strField1) = varLastVal1 Then
-
Call .Delete
-
Else
-
varLastVal = .Fields(strField)
-
varLastVal1 = .Fields(strField1)
-
-
End If
-
Call .MoveNext
-
Loop
-
'Ending the 'With' releases the Recordset
-
End With
-
End Function
thank you
When posting your question it is necessary to put it in its own thread. Hijacking somebody else's (Delete Duplicate records) is not acceptable.
Careful, NeoPa! You appear to be discipling someone in public!
Linq ;0)> NeoPa 32,579
Recognized Expert Moderator MVP
Ah well Linq my friend. I'm still sane aren't I.
NeoPa 32,579
Recognized Expert Moderator MVP ahmedtharwat19: but what the condition if there 2 fields
i try it and it work as well
Indeed. It seems you have understood the concept well enough to modify it for slightly changed circumstances.
Well done :)
@NeoPa
yes, thank you for all.
@NeoPa
I'm sure you are, Ade, but apparently some are not!
Linq ;0)> @NeoPa
i`m sorry idont understand what do you mean , i just add this for that thread to complete the thread in same problem.
Generally, thank you for an advice.
Best Regards ,
Medo
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mirek Rusin |
last post by:
....what is the best way to force duplicated unique
or primary key'ed row inserts not to raise errors?
duplicated rows can be ignored or updated as well
- it really doesn't matter.
to be specific, i've got:
$ psql -d mydb -c "copy mytable from 'mytable.tsv'
|
by: Andrew DeFaria |
last post by:
I created the following .sql file to demonstrate a problem I'm having.
According to the manual:
If |ON DELETE CASCADE| is specified, and a row in the parent table
is deleted, then InnoDB automatically deletes also all those rows in
the child table whose foreign key values are equal to the referenced
key value in the parent row.
However:
|
by: Patrizio |
last post by:
Hi All,
I've the following table with a PK defined on an IDENTITY column
(INSERT_SEQ):
CREATE TABLE MYDATA (
MID NUMERIC(19,0) NOT NULL,
MYVALUE FLOAT NOT NULL,
TIMEKEY INTEGER NOT NULL,
TIMEKEY_DTTM DATETIME NULL,
|
by: GlobalBruce |
last post by:
The GAC on my development computer has several assemblies which are
duplicated. For instance, the System assembly is present as two different
native images as well as the non-native version. The native images differ by
date/time stamp -- although they are only different by 3 days during Feb/2004.
Many of the System assemblies have similar duplicated native images.
Why are there multiple copies of these assemblies?
Is it safe, useful,...
|
by: robert |
last post by:
been ruminating on the question (mostly in a 390/v7 context) of
whether, and if so when, a row update becomes an insert/delete.
i assume that there is a threshold on the number of columns of
the table, or perhaps bytes, being updated where the engine just
decides, screw it, i'll just make a new one.
surfed this group and google, but couldn't find anything.
the context: we have some java folk who like to parametize/
| |
by: Dejan |
last post by:
Hy,
Sorry for my terreble english
I have this simple code for deleting rows in mysql table...
Everything works fine with it.
So, what do i wanna do...:
my sql table looks something like this:
id Name Surname pictr0 picrt1 pictr2
pictr3
|
by: Ryan Liu |
last post by:
Hi,
If I have tens of thousands DataRow in a DataTable and allow the end user to
pick any DataColumn(s) to check for duplicated lines, the data is so large,
is there a better API, algorithm can be used for this purpose?
Thanks a lot!
Ryan
|
by: Radu |
last post by:
Hi.
I have a "union" table which results of a union of two tables.
Occasionally I could have duplicates, when the same PIN has been added
to both tables, albeit at different Datees/Times, such as:
PIN Name Added Date
100411 A 7/11/2007 10:12:58 AM
100411 A 7/17/2007 10:54:23 AM
100413 B 7/11/2007 10:13:28 AM
|
by: Michel Esber |
last post by:
Hello,
Environment: DB2 LUW v8 FP15 / Linux
I have a table with 50+ Million rows. The table structure is basically
(ID - Timestamp). I have two main applications - one inserting rows,
and the other reading/deleting rows.
The 'deleter' application runs a MIN/MAX (timestamp) for each ID and,
if the difference between min/max is greater than 1h, it reads all
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |