PC Review


Reply
Thread Tools Rate Thread

Duplicates - How to prevent from TWO columns?

 
 
Tim McGavin
Guest
Posts: n/a
 
      2nd Jun 2007
I currently have a column called "email". I have prevented duplicates from
existing by changing the "Indexed" property to have a "Yes (No Duplicates)"
value.

But I just recently added another column called "email2". How can I prevent
duplicates from existing between both columns together?

In other words, if I enter an email address in "email" and it exists
somewhere in "email2" then I would like for the system to catch that as a
duplicate.

What are the best ways to do this?

Tim


 
Reply With Quote
 
 
 
 
Jeff Boyce
Guest
Posts: n/a
 
      2nd Jun 2007
Tim

One approach would be to use a new table structure.

One of my applications has to handle the situation that one entity (person,
org, agency, ...) can have zero, one or many addresses (and phone numbers,
and email addresses). To manage this requirement, there are three tables
(using your email example):

tblEntity

tblEmailAddress

trelEntityEmailAddress

This third table holds valid combinations of Entity and EmailAddress. This
allows one Entity to have many (or even no) email addresses, and one
EmailAddress to be used by many Entities (not so necessary anymore, with the
proliferation of free emailer ISPs, but each/every person in a family may
still use the same generic email address).

If you index the trelEntityEmailAddress columns to prevent duplicate Entity
X EmailAddress combinations, this would achieve your requirement as I
understood it (i.e., no Entity should have duplicate email addresses).

--
Regards

Jeff Boyce
Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


"Tim McGavin" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I currently have a column called "email". I have prevented duplicates

from
> existing by changing the "Indexed" property to have a "Yes (No

Duplicates)"
> value.
>
> But I just recently added another column called "email2". How can I

prevent
> duplicates from existing between both columns together?
>
> In other words, if I enter an email address in "email" and it exists
> somewhere in "email2" then I would like for the system to catch that as a
> duplicate.
>
> What are the best ways to do this?
>
> Tim
>
>


 
Reply With Quote
 
Tim McGavin
Guest
Posts: n/a
 
      4th Jun 2007
I'm sure I understand your solution which leads me to believe that maybe I
didn't explain myself very well.

So here goes again...

I have these colums....

email
email2

The first column might contain addresses like this...

(E-Mail Removed)
(E-Mail Removed)
(E-Mail Removed)

And the second column might contain the same type of data.

But I want Access to disallow the entry of the same email address in either
column.

In other words, if column "email" contains (E-Mail Removed) the I should not be
able to enter (E-Mail Removed) into the "email2" column.

Help!


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      4th Jun 2007
You cannot do it at a table level in Access.

The only way to do it is using a form. In the form's BeforeUpdate event,
you'd put code to check whether or not the new value already exists in
either of the two fields.

However, having two such fields, both of which are intended to hold the same
data, suggests that the table hasn't been properly normalized.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tim McGavin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm sure I understand your solution which leads me to believe that maybe I
> didn't explain myself very well.
>
> So here goes again...
>
> I have these colums....
>
> email
> email2
>
> The first column might contain addresses like this...
>
> (E-Mail Removed)
> (E-Mail Removed)
> (E-Mail Removed)
>
> And the second column might contain the same type of data.
>
> But I want Access to disallow the entry of the same email address in
> either column.
>
> In other words, if column "email" contains (E-Mail Removed) the I should not
> be able to enter (E-Mail Removed) into the "email2" column.
>
> Help!
>



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      5th Jun 2007
On Mon, 4 Jun 2007 13:54:22 -0500, "Tim McGavin" <(E-Mail Removed)> wrote:

>I'm sure I understand your solution which leads me to believe that maybe I
>didn't explain myself very well.
>
>So here goes again...
>
>I have these colums....
>
>email
>email2
>
>The first column might contain addresses like this...
>
>(E-Mail Removed)
>(E-Mail Removed)
>(E-Mail Removed)
>
>And the second column might contain the same type of data.
>
>But I want Access to disallow the entry of the same email address in either
>column.
>
>In other words, if column "email" contains (E-Mail Removed) the I should not be
>able to enter (E-Mail Removed) into the "email2" column.
>
>Help!
>


You cannot do this in a Table. You can use a unique index on a field to
prevent duplicates in that field, but you're paying the price for having
repeated fields: your table design is not normalized, so the tools for
handling normalized data won't work.

The only way I can think of to do this would be to use VBA code in the form's
BeforeUpdate event to use DLookUp on both fields to see if there is a
duplicate, and cancel the event if so. If you're entering data directly into
tables, you're out of luck - and shouldn't be doing so.

John W. Vinson [MVP]
 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      5th Jun 2007
Tim

As you've seen from a couple other responses, it is not recommended use the
approach you've described. That's why I offered an alternate approach.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/


"Tim McGavin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm sure I understand your solution which leads me to believe that maybe I
> didn't explain myself very well.
>
> So here goes again...
>
> I have these colums....
>
> email
> email2
>
> The first column might contain addresses like this...
>
> (E-Mail Removed)
> (E-Mail Removed)
> (E-Mail Removed)
>
> And the second column might contain the same type of data.
>
> But I want Access to disallow the entry of the same email address in

either
> column.
>
> In other words, if column "email" contains (E-Mail Removed) the I should not

be
> able to enter (E-Mail Removed) into the "email2" column.
>
> Help!
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Duplicates Summing multiple fields on a form Microsoft Access Getting Started 3 27th Mar 2010 04:58 PM
Prevent Duplicates jwrnana Microsoft Access Reports 9 8th Nov 2005 03:36 PM
How to prevent duplicates? jwr Microsoft Access Reports 5 30th Oct 2005 03:04 PM
Prevent Duplicates scottnshelly Microsoft Excel Programming 4 13th Jul 2004 01:48 AM
Prevent Duplicates bw Microsoft Access Form Coding 3 17th Jun 2004 07:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:58 PM.