Manufacturing Information Solutions Forum Index Manufacturing Information Solutions
Your Place for Support and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delete Confirmation

 
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access
View previous topic :: View next topic  
Author Message
BIGmiralli
Frequent Poster


Joined: 17 Apr 2007
Posts: 38
Location: Boston, Massachusetts

PostPosted: Fri Jan 04, 2008 11:54 am    Post subject: Delete Confirmation Reply with quote

Hello every one, how can I have a delete routine with my own message rather than having the Access promt?

Thanks.
________
Indica strains


Last edited by BIGmiralli on Wed Feb 16, 2011 10:40 am; edited 1 time in total
Back to top
View user's profile Send private message
JoeM
Master Poster


Joined: 09 Jul 2004
Posts: 122
Location: Jackson Hole, Wyoming USA

PostPosted: Fri Jan 04, 2008 11:58 am    Post subject: Reply with quote

Delete Confirmation
This code prompts the user if they realy want to delete a record


Code:
Sub btn_Delete_Click ()
On Error GoTo Err_btn_DeleteElement_Click
'**This whole section just prompts the user if they realy want to delete the record.

DoCmd SetWarnings False                 '**Turns warning message off

Const MB_OK = 0, MB_OKCANCEL = 1                       '** Define buttons.
Const MB_YESNOCANCEL = 3, MB_YESNO = 4
Const MB_ICONSTOP = 16, MB_ICONQUESTION = 32     '** Define icons.
Const MB_ICONEXCLAMATION = 48, MB_ICONINFORMATION = 64
Const MB_DEFBUTTON2 = 256, IDYES = 6, IDNO = 7       '** Define other.
title = "Think About What You Are Doing"

'** Put together a sample message box with all the proper components.
Msg = "Are you sure you want to DELETE this Tool?"   '**Chnage this to fit your needs
Msg = Msg & " If so, click Yes"
DgDef = MB_YESNO + MB_ICONSTOP + MB_DEFBUTTON2      '** Describe dialog box.
Response = MsgBox(Msg, DgDef, title)                   '** Get user response.

If Response = IDYES Then                                  '** Evaluate response
    Msg = "The record WAS deleted."                       '** and take appropriate

    'Version 2
    ' DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_V2, , A_MENU_VER20
    ' DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_DELETE_V2, , A_MENU_VER20

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


Else                                                         '** Take action.
    Msg = "You chose No or pressed Enter, the recorord will not be deleted."
End If
  title = ""
Response = MsgBox(Msg, , title)                           '** Display action taken.

DoCmd SetWarnings True                                    '**Turns Warning back on


Exit_btn_DeleteElement_Click:
    Exit Sub

Err_btn_DeleteElement_Click:
    MsgBox Error$
    Resume Exit_btn_DeleteElement_Click

End Sub


Just change your messages and titles and you should be good.
Back to top
View user's profile Send private message Send e-mail
dawn
Master Poster


Joined: 26 Jun 2004
Posts: 311
Location: Mishawaka, IN

PostPosted: Fri Jan 04, 2008 12:39 pm    Post subject: Reply with quote

There are two slight differences in versions later then Access 2.0 in your Delete Confirmation code:

Code:
DoCmd.SetWarnings False                   '**Turns warning message off
and
Code:
DoCmd.SetWarnings True                    '**Turns Warning back on


Note the period in: DoCmd.SetWarnings
_________________
Dawn Mitchell
Manufacturing Information Solutions
www.mis-group.com
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group