By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

check for duplicates

P: n/a
I need a form to check for duplicates before a new record is added.
Table name: Links
Field1: LinkSysNum
Field2: SysNum

For example, [LinkSysNum]=539 is linked to [SysNum]=540
[SysNum]=544

The db is setup using a union query to cross link the records. The
form needs to be able to look at the record it is about to create and
if it finds that it is already there give a msg.

Thanks
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
TC
Say the user types the potentially duplicated value into a textbox.

Use a DLookup() function in the BeforeUpdate event of that textbox. If the
DLookup() finds an exsting record, it can display a message using the
Msgbox() function, then set the Cancel parameter for the BeforeUpdate event.
This will stop the form accepting that value.

HTH,
TC
"Josh Armstrong" <jo***********@socal.rr.com> wrote in message
news:b6**************************@posting.google.c om...
I need a form to check for duplicates before a new record is added.
Table name: Links
Field1: LinkSysNum
Field2: SysNum

For example, [LinkSysNum]=539 is linked to [SysNum]=540
[SysNum]=544

The db is setup using a union query to cross link the records. The
form needs to be able to look at the record it is about to create and
if it finds that it is already there give a msg.

Thanks

Nov 12 '05 #2

P: n/a
jo***********@socal.rr.com (Josh Armstrong) wrote in message news:<b6**************************@posting.google. com>...
I need a form to check for duplicates before a new record is added.
Table name: Links
Field1: LinkSysNum
Field2: SysNum

For example, [LinkSysNum]=539 is linked to [SysNum]=540
[SysNum]=544

The db is setup using a union query to cross link the records. The
form needs to be able to look at the record it is about to create and
if it finds that it is already there give a msg.

Thanks


If the two fields (LinkSysNum,SysNum) comprise, the primary key, then
you *cannot* add duplicates. Why not make use of what the database
will do for you instead of making work for yourself?
Nov 12 '05 #3

P: n/a
> > I need a form to check for duplicates before a new record is added.
Table name: Links
Field1: LinkSysNum
Field2: SysNum

For example, [LinkSysNum]=539 is linked to [SysNum]=540
[SysNum]=544

The db is setup using a union query to cross link the records. The
form needs to be able to look at the record it is about to create and
if it finds that it is already there give a msg.

Thanks


If the two fields (LinkSysNum,SysNum) comprise, the primary key, then
you *cannot* add duplicates. Why not make use of what the database
will do for you instead of making work for yourself?

I thought about that, but the 2 fields do not make up the primary key.
I was not able to do that as it is set up such that
Record A is linked to Record B
If you look at Record B you will see A and vis-versa

If you Start will B and add the Link to A then you now have a dupe
record.
AB
BA

I need to check for both before saving the new record.
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.