Reputation: 465
I have a form that lets you click "more info" on a record, and it pops up a form (SupplierInfoF) with more information about that record by showing all the information in text boxes; the form it pops up has a record source attached to a query (SupplierMoreInfoQ) which is attached to the table. So if I edit the fields, it edits them on the table. Though I would like to add a DELETE button on this form, where if you push it it pops up a msgbox asking if you are sure you want to delete this record, and if you push yes it deletes the record and puts you back on the previous form (SupplierListF). How would I go about doing this?
Upvotes: 0
Views: 541
Reputation: 15048
The below code allows you to take over control of the deletion and not allow Access to show its warning. Once the delete is done the form closes.
If MsgBox("Are you sure that you want to delete this record?", _
vbInformation + vbYesNo, _
"DELETION REQUEST") = vbYes Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
DoCmd.Close
End If
Upvotes: 1