Results 1 to 10 of 10
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Need a message to warn before deleting a record


    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?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    put a message in the form before delete event which requires a yes/no answer - if the user cancels, set cancel =true

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Sounds like a plan. But, I'm not sure how to do that.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    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

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    beaten to it

  6. #6
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    It's looking like it's more than I know how to do. I made a delete button from Access to delete the current record. I didn't make the embedded macro, Access did. Where does the code go? Click image for larger version. 

Name:	Delete Button.jpg 
Views:	26 
Size:	56.8 KB 
ID:	27380

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    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?

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    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.

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    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.

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-08-2012, 10:38 AM
  2. Deleting current record using VBA
    By Kivan in forum Programming
    Replies: 3
    Last Post: 08-07-2012, 11:31 AM
  3. Deleting a record
    By alexc333 in forum Access
    Replies: 7
    Last Post: 07-26-2011, 10:43 AM
  4. Problem deleting record
    By Vikki in forum Access
    Replies: 8
    Last Post: 02-26-2010, 11:07 AM
  5. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums