What does this do? - Deleting records from subforms

KjWhal

Registered User.
Local time
Today, 14:30
Joined
Jan 5, 2007
Messages
60
I have a subform that I'd like to put a delete button on, so that it deletes each specific record. This was left over by the previous programmer for this purpose but without any documentation, and it doesn't seem to work as intended.

Using the below code allows you to delete the record, but you can never re-add it in any capacity. It says it would create a duplicate value (not true) in the key or index. The index is duplicates OK.

If MsgBox("are you sure you want to delete this?", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
End If
 
Try sticking

else
exit sub

between the docmd.setwarnings true and end if

I tried that, no change in the problem.

I also tried doing it via SQL and that will delete the record, but the problem of the duplication error message persists. What forum could most likely handle this issue?
 

Users who are viewing this thread

Back
Top Bottom