Duplicate delete prompt issue

mrtn

Registered User.
Local time
Today, 19:07
Joined
Dec 16, 2010
Messages
43
Hi

I've got a continuous subform which is bound to a local table. The subform has record selectors which are used to delete individual records from the subform.

I have noticed that if only one record is selected, the user is prompted to confirm deletion. If no is clicked, the prompt comes up again. I've removed everything else from the parent form, together with any other code just to narrow down the list of potential issues. I have now been left with no code (other than debugging prompts) but the prompt still comes up. I can see that before delete, delete and after delete are fired twice for an attempted deletion of a single record.

I've attached a copy of the db with some sample data where you will be able to reproduce it.

Any help would be much appreciated.
 

Attachments

Hi,

Perhaps you stripped it back too much!

I could delete each record displayed in the subform by clicking on the record selector and hitting the 'Delete' key.

Each time I was asked if I wanted to delete 1 record and, on confirming, one record was deleted.

Code:
Delete Event - 11:06:44
Before Del Confirm Event - 11:06:44
After Del Confirm Event - 11:06:46
Delete Event - 11:06:48
Before Del Confirm Event - 11:06:48
After Del Confirm Event - 11:06:51
 
I am beginning to wonder whether I should run a repair of my Office package.

Just to clarify - this is what I do and what happens:

1. Select the first record - direction Buy
2. Hit delete key
3. I get the first prompt at this point - 'You are about to delete 1 record'
4. Select No
5. The record temporarily disappears from the subform
6. The same prompt pops up
7. Select No again
8. The holding re-appears in the subform
 
I can reproduce this behavior. It is not a problem of your Office.
 
Now the interesting part- when the subform is opened as a standalone form, I only get one prompt...

The prompt only shows once if you select 'Yes' in the first step
 
>> Now the interesting part- when the subform is opened as a standalone form, I only get one prompt... <<

I just got the same result
 
>> Now the interesting part- when the subform is opened as a standalone form, I only get one prompt... <<

I just got the same result

Any ideas how to tackle it? just checked and it only happens with a continuous form, works OK in datasheet view
 
This seems like a horrible hack, so if anyone knows the root cause of this issue it would be better to fix that!

In your subform module (Reviews sfrm trade list) add a module level variable:
Code:
Option Compare Database
Option Explicit           ' <-- Also add this to the top of EVERY code module

Private LastDelID As Long

Private Sub Form_Delete(Cancel As Integer)

  If Not LastDelID = Me.LocalTrade_ID Then
    LastDelID = Me.LocalTrade_ID
  Else
    LastDelID = 0
    Cancel = True
  End If

End Sub
Basically, on first delete attempt it captures the PK of the record.
Then on the subsequent attempt to delete it compares with the captured ID and cancels the event if it's the same (and resets the captured ID).

hth,

d
 
Really strange. only subform works ok. no code at all!
I created the same from scratch and works well

I believe a db file corruption, subform corrupted. I created a new subform and works well
 
>> I created a new subform and works well <<

Excellent - I didn't bother to test that! :oops:

A much better solution! 👍

d
 
Thanks for your help chaps. Much appreciated.
 

Users who are viewing this thread

Back
Top Bottom