modify code for deleting records

  • Thread starter Thread starter Liane
  • Start date Start date
L

Liane

Guest
This is the code that access generates when you create a command button to delete a record. I would like to change this so that it includes my own message box like "Are you sure you wish to delete this record" and then a yes or no button. I don't want the access messages it shows.


Private Sub Delete_Click()
On Error GoTo Err_Delete_Click

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

Exit_Delete_Click:
Exit Sub

Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click

End Sub

Thank-you
 
use the command button to open msg box then add the codes you want to VB yes VBno
 
Try this:

Private Sub Delete_Click()
On Error GoTo Err_Delete_Click

if msgbox("Are You Sure?",vbYesNo + vbQuestion)=vbyes then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
end if

Exit_Delete_Click:
Exit Sub

Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom