Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Message box: 'Are you sure you want to delete?' (Access 2000)

    I have a button on a form that runs a macro. The macro runs a delete query. The delete query deletes all records from one table. I'd like to have a message box come up after pressing the button asking "Are you sure you want to delete ..." and have a Yes/No button. After clicking Yes, go ahead and do the delete. After clicking No, just cancel the delete.

    I could use the default messages that appear when running the delete query, but I want to customize it so it's simpler for my users to understand.

    What's the best way to do this? In code, something in a macro? What function do I use? Msgbox function doesn't provide me much.

    Thanks, sarah

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Message box: 'Are you sure you want to delete?' (Access 2000)

    Maybe someone will have a way to do it in a Macro, but I would suggest you do it in VBA code. If you do the MsgBox function is exactly what you are looking for.

    <pre>If MsgBox("Are you sure you want to delete these records?", _
    VBYesNo + VBQuestion, "DeleteRecords") = vbYes then
    <font color=448800>'Run your delete query here</font color=448800>
    CurrentDB().Execute "SavedQueryName"
    Else
    <font color=448800>'Don't run the Delete query</font color=448800>
    End If</pre>


    HTH
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Message box: 'Are you sure you want to delete?' (Access 2000)

    Hey Bryan!

    You're such a smarty! The code worked perfectly. Thanks for the help!
    <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

    Sarah

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Message box: 'Are you sure you want to delete?' (Access 2000)

    You're welcome.

    Glad it worked for you.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •