I need to make a warning in Access 2013 so that the user gets a warning before he accidentally deletes a record. I think it's done with a macro. Anyone know how to?
I need to make a warning in Access 2013 so that the user gets a warning before he accidentally deletes a record. I think it's done with a macro. Anyone know how to?
put a message in the form before delete event which requires a yes/no answer - if the user cancels, set cancel =true
Sounds like a plan. But, I'm not sure how to do that.
From HELP: Form.BeforeDelConfirm Event
Try
Code:Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer) ' Suppress default Delete Confirm dialog box. Response = acDataErrContinue ' Display custom dialog box. If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then Cancel = True End If End Sub
beaten to it
I don't use macro's but suggest probably between if not form.newrecord and runmenucommand - you'll need to use the macro equivalent of the vba code
Are you sure it is not generating it's own warning message anyway?
It does generate it's own warning. I wanted a much more pointed warning because I know that someone will say that he never saw it. Until I understand it better, it will do. Thank you.
it may be what you want cannot be done with a macro - they are quite limited compared with VBA.
In design view, select the form properties, select the events tab and scroll down to before del confirm, about 8 events down. Click on the 3 dot carat to the right and select Code Builder to open the VBA window. Then just copy and paste ssanfu's code. change the message if required.
It can be done with a macro.. its just overly complicated. I've done it myself and cant remember how. All the answers are here for you though.
Make sure "form" selected on the p[properties pane. in the "Event" tab on the properties look for "before Del Confirm" and then paste in that code.
Id defiantly recommend using VBA even if you're clueless. After some time you will pick up the basics.