Deleting duplicate entry in subform 
Author Message
 Deleting duplicate entry in subform

I have a db that keeps track of various departmental projects. On my
main form, I have a subform that allows the user to add which
division(s) is(are) involved for that particular project. The subform's
only control is a combobox that lists possible divisions from a lookup
table. The values entered are stored in a table that handles the
many-to-many relationship between projects and divisions. So:

cboProjectDivisionID resides in
sfrProjectDivison which is on
frmProjects

cboProjectDivisionID updates
tblProjectDivision which has a multi-key index,
ProjectDivision, which includes ProjectID and DivisionID
and is set to require Unique Values, since I don't want people to input
the same division twice for a particular project.

So, I get the "duplicate values" error. What I would like to do is this:
When the person ok's the error message, I would like the offending
record deleted, so that the user doesn't have to do that. I have tried
attaching error-trapping code (I think the error I'm looking at is 3022)
in the BeforeUpdate, AfterUpdate and Change events of
cboProjectDivision, but it gives me all sorts of errors that don't
relate to the problem at hand. If I take the specialized error-trapping
out, (leaving in my generic error-trapping), it runs fine, but the
duplicate record has to be taken out by hand. Any ideas?



Sat, 10 Feb 2001 03:00:00 GMT  
 Deleting duplicate entry in subform
The error happens when Access tries to save the record, so it happens before
the After update event.

What you need to do is to use the [Form Error] Event to trap all the
possible Jet's errors.

In your particular case, simply using [DoCmd.RunCommand acCmdDeleteRecord]
should delete the duplicated record.  If this one doesn't work try
[SendKeys "{ESC}"] twice
(it's not very elegant but it will certainly work ).

Hope this helps!

===============
  Robert Bolduc
===============

Erika Sparks wrote
...

Quote:
>So, I get the "duplicate values" error. What I would like to do is this:
>When the person ok's the error message, I would like the offending
>record deleted, so that the user doesn't have to do that. I have tried
>attaching error-trapping code (I think the error I'm looking at is 3022)
>in the BeforeUpdate, AfterUpdate and Change events of
>cboProjectDivision, but it gives me all sorts of errors that don't
>relate to the problem at hand. If I take the specialized error-trapping
>out, (leaving in my generic error-trapping), it runs fine, but the
>duplicate record has to be taken out by hand. Any ideas?



Sun, 18 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. An easy solution here (VBA code) to delete duplicate entries (email, calendar or task entries) in Outlook

2. Subform Issue -- Duplicate Records

3. Real-time checking of duplicate entries

4. before saving a record, check duplicate entries

5. Detecting Duplicate Entries On Direct Input

6. Checking For Duplicate Entries using VBA

7. validartion code for duplicate entries

8. Duplicate entries when coping items with VBA macro

9. Duplicate contact Entries

10. Duplicate entries when coping items with VBA macro

11. Duplicate form entry problem with new form

12. Duplicate entries in custom form

 

 
Powered by phpBB® Forum Software