Add and save record in continuous form with buttons

On Error Resume Next
Forms!MainForm.SetFocus
Forms!MainForm!Subform.SetFocus
DoCmd.RunCommand acCmdDeleteRecord
 
On Error Resume Next
Forms!MainForm.SetFocus
Forms!MainForm!Subform.SetFocus
DoCmd.RunCommand acCmdDeleteRecord
Yeah, that's what I thought too. He needs to move the focus to the subform first.
 
IMO it is a lot more intuitive to the user to put the buttons on the subform or continuos form next to the record. As long as you have the real estate.
edit delete.jpg

Or at least make it very clear what is the active record
hilite.jpg
 
And always, always, always give the user a chance to cancel deleting a record. I use this on all my record delete routines:
Code:
Dim Reply As Variant
Reply = MsgBox("THIS ACTION DELETES THIS RECORD." & Chr(10) & Chr(10) & "DO YOU WANT TO DO THIS?", vbYesNo)
If Reply = 7 Then 'NO
    DoCmd.CancelEvent
    Exit Sub
End If
If Reply = 6 Then 'Yes
    DoCmd.RunCommand acCmdDeleteRecord
    Me.Form.Requery
End If
 
And always, always, always give the user a chance to cancel deleting a record.
Deleting records is not considered as a good practice.
It's better to mark the record as deleted. I have a DeletedDate field in all my tables. If a user deletes a record, DeletedDate field is populated and it's considered as deleted. It will not show in search results unless the user tick a checkbox (include deleted records) in search form.

In some cases, the user can not delete a record unless adding the reason. I save the UserID, date and the reason the record was deleted.
 
Last edited:
So far no one has suggested trying to use Access to solve the problem rather than create a complex solution.
See post #17, that suggestion already made.
 

Users who are viewing this thread

Back
Top Bottom