Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

VickyC (TechnicalUser) (OP)
25 Feb 12 12:21
hello to all

I am using code behind a command button that attempts to save a record in one table (tblA) to another (tblB).

tblB has an autonumber ID and 20 records (I1, I2, ...I20) that can hold integer values.  These 20 integer records are from tblA.

Here's my problem.  I don't want to allow the save to tblB if the set of 20 integer values already exists in tblB.  I've tried setting a pk on the combination of all 20 fields, but this would fail because some of the fields may be null.

I could actually get this to work properly using a very large DCount expression (in a BeforeUpdate event) whose 'WHERE' part compares all 20 fields in both tables, then stops the save where DCount > 0.  But, this seems excessively complicated.  

Is there an easy way to ensure that records (that may include null fields) are not duplicated?  I feel like I'm missing something obvious.

thanks for any assistance
Vicky C.
Helpful Member!  MajP (TechnicalUser)
25 Feb 12 14:19
I assume tblB has an ID and 20 Fields, not an ID and 20 records.

I would build a query and store it, that compares all the fields. You would have to wrap the values in a NZ in the query. It is not going to be any shorter than the Dcount, but it would be a lot easier to build and maintain using a query, and should be more efficient.  Then you can use a very simple dcount on that query. If it returns 1 record you have a match.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close