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
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