Delete Button Deleting too many Records

Kitwolf

New member
Local time
Today, 15:19
Joined
Jan 14, 2010
Messages
7
Hello there,
I have a strange situation. I have a columnar form with a sub-form based on an updatable query. I've created a delete button on the master form with the intention that if the user hits the delete button, it will delete the current record (like its supposed to, right?).
But what is happening is when the delete button is hit, it is asking twice for deletion confirmation and deleting the current record AND the next record. Even if I hit "Cancel" to stop the deletion, it still deletes the current and next records.
Each record has a primary unique ID that is included on the form (but not tab stopped - if that makes any difference), but it doesn't seem to be using that as the basis for deleting.

I've tried two different codes for this:

Private Sub Command110_Click()
On Error GoTo Err_Command110_Click
DoCmd.RunCommand acCmdDeleteRecord
Exit_Command110_Click:
Exit Sub
Err_Command110_Click:
MsgBox Err.Description
Resume Exit_Command110_Click
End Sub

and:

Private Sub Command111_Click()
On Error GoTo Err_Command111_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command111_Click:
Exit Sub

Err_Command111_Click:
MsgBox Err.Description
Resume Exit_Command111_Click
End Sub

Any ideas what is going wrong here? Really appreciate any help!!!
 
Last edited:
Try selecting the record first:
Code:
Private Sub Command110_Click()

On Error GoTo Err_Command110_Click
 
DoCmd.RunCommand acCmdSelectRecord

DoCmd.RunCommand acCmdDeleteRecord

Exit_Command110_Click:
Exit Sub
Err_Command110_Click:
MsgBox Err.Description
Resume Exit_Command110_Click

End Sub
Linq ;0)>
 
Thanks Linq, but same thing happened again. I copied your code and put it in on the onClick line, but again, it is still deleting current + next record.
Very odd.
 
Only other thing I can think of is that the Command Button Control is corrupted. Although we usually think of Forms or entire Databases when we speak of corruption, individual Controls, such as Command Buttons, can and do become corrupted. The test and the fix are one and the same; deleting the Control then re-creating it! If it was corrupt, you've verified the fact and solved the problem! If not, you've only lost a minute or two!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom