Eliminate Duplicates (1 Viewer)

kike79

Registered User.
Local time
Today, 11:14
Joined
Oct 24, 2011
Messages
11
Hi everybody

I would like to know how to eliminate duplicates from a text box, I have mail.text that contains email addresses, but it can contain the same email address several times and I just nees one instance of every email address

Any suggestion???

Thank you
 

mdlueck

Sr. Application Developer
Local time
Today, 12:14
Joined
Jun 23, 2011
Messages
2,631
I would first lowercase each email addy to prevent dupes based on different case. Strip leading / trailing space characters as well.

Then I would check for its existance in a Collection class object, where you can make a string the thing that uniquely identifies the object within the set of objects. The Collection class supports a Key, and that is the thing to place the email addy string into. If not found, add the email addy to the list, and add it to the collection. Next time it would already be in the collection, thus skip.

Once fully loaded, you may safely dispose of the collection object.
 

kike79

Registered User.
Local time
Today, 11:14
Joined
Oct 24, 2011
Messages
11
Any code suggestion??? I'm clueless


I would first lowercase each email addy to prevent dupes based on different case. Strip leading / trailing space characters as well.

Then I would check for its existance in a Collection class object, where you can make a string the thing that uniquely identifies the object within the set of objects. The Collection class supports a Key, and that is the thing to place the email addy string into. If not found, add the email addy to the list, and add it to the collection. Next time it would already be in the collection, thus skip.

Once fully loaded, you may safely dispose of the collection object.
 

kike79

Registered User.
Local time
Today, 11:14
Joined
Oct 24, 2011
Messages
11
Thank you Alan, but this field is a calculated field, another suggestion?
 

Alansidman

AWF VIP
Local time
Today, 11:14
Joined
Jul 31, 2008
Messages
1,493
This raises a new question
Why are you storing calculated information in a table? Calculations, normally, should be in forms and queries.

In your original post you indicated that you were looking for email addresses that were duplicates, unless I misunderstood the issue. Please clarify specifically, what are you trying to do.

I am now very confused by this thread.
 

kike79

Registered User.
Local time
Today, 11:14
Joined
Oct 24, 2011
Messages
11
No, I'm not working with tables, I just have a text field and need to extract a instance of every email in that text field
 

Alansidman

AWF VIP
Local time
Today, 11:14
Joined
Jul 31, 2008
Messages
1,493
So this is an unbound text box on a form? Perhaps, it is time for you to explain specifically what you are doing. I don't understand the situation. Post a sample of your data so that we can look at it and have a better understanding.

Alan
 

vbaInet

AWF VIP
Local time
Today, 17:14
Joined
Jan 22, 2010
Messages
26,374
You said that the field is a calculated field, so get the e-mail addresses before the calculation and get rid of the duplicates.

We need to know what kind of calculation you are performing.
 

mas123

Registered User.
Local time
Today, 18:14
Joined
Jun 27, 2007
Messages
12
if my understanding is true
you need to check if the e-mail you are typing in the textbox is entered or not?
and if the e-mail exists the code displays alert
is this is true??!!
 

vbaInet

AWF VIP
Local time
Today, 17:14
Joined
Jan 22, 2010
Messages
26,374
if my understanding is true
you need to check if the e-mail you are typing in the textbox is entered or not?
and if the e-mail exists the code displays alert
is this is true??!!
No, not really. kike79 has a field that has a string of e-mail addresses and he/she wants to extract distinct e-mail address from that field.
No, I'm not working with tables, I just have a text field and need to extract a instance of every email in that text field
 

EssexRich

Registered User.
Local time
Today, 17:14
Joined
Nov 18, 2011
Messages
18
OK, how about copying the contents into a text file in notepad and importing them? Use a semi colon as a seperator.

Then once they're in a table, you can copy and paste the table's structure only. Then set the email address field to No Duplicates. Finally, you can then copy all the records from the imported data into this new table and it will paste in the records but minus any duplicates which will fail.

hope this helps,

Rich
 
Last edited:

hudson426

Registered User.
Local time
Today, 17:14
Joined
Jun 19, 2009
Messages
28
Hi

I've used this a few times in my own databases

Example

Table1 - This contains all your email addresses (inc duplicates). Lets say that field "email" conatains all your email addresses

Create a query, 1 field, email
Press the Sigma (Totals) button from the tool bar
This will group all like email addresses together
Save Query (Query1)

Create a form
Create a text box (or a pull down list) using Query1 as your source data

As the text box is using Query1 as its source and as Query1 has grouped all identical email addresses into just one record, then the text box will only show unique email addresses.

Hope this helps
 

tezread

Registered User.
Local time
Today, 17:14
Joined
Jan 26, 2010
Messages
330
Can you not store the email addresses in a table and have the field 'email' indexed with 'no duplicates' selected?
 

jdraw

Super Moderator
Staff member
Local time
Today, 12:14
Joined
Jan 23, 2006
Messages
15,397
Some more questions.

If you're not using a table, where do the email addresses come from?

Once the "email address (s)" get to your text box, can they every be NULL/empty? You don't mention this condition, but do you check for it?

Do all "email addresses in the text box" have a ; terminator?

Code to check for empty:
if isnull(me.textbox) then Goto Loop_to_bypass_This_Email

Code to check for 1 or more emails in the textbox:
me.textbox = Trim(me.textbox)
if(Instr(me.textbox,";") > 0 then
me.textbox = Mid(me.textbox,1,Instr(me.textbox,";") -1)
end if
'at this point there is only 1 email address in the textbox

(Code is untested)
 

Users who are viewing this thread

Top Bottom