Modifying A Wizard Created Delete Button

catbeasy

Registered User.
Local time
Today, 05:35
Joined
Feb 11, 2009
Messages
140
I used the (msaccess 97 ) wizard to create a delete button placed on a form.

The button works fine; however, When I click the button and select no to deleting the record, I get what appears to be a standard MS msgbox that says "The DoMenuItem was canceled.." and some other stuff that would probably confuse a user. It also sends you to the last record and since I am using the continuous forms view, if, for example, you have 3 records showing before you hit delete, now it looks like you only have 1! Of course, you can just hit the navigation button to bring them back, but this appears to me an unecessary potential confusion for the user (note, to get around this, I add some code under the "Exit_Command6_Click:
" code to go to the first record which solves this issue)..

My question is, how do I get rid of the MS Access generated message and insert my own more user friendly message if the user selects to cancel the delete request. Also, is there anywhere that shows what the instrinsic constant values refer to? 8 and 6 don't help much..

Thanks for any help..here is the code that the wizard generated..(with the exception of: DoCmd.GoToRecord acDataForm, "frm_view_assoc_rec", acFirst.

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command6_Click:
DoCmd.GoToRecord acDataForm, "frm_view_assoc_rec", acFirst
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
 
I used the (msaccess 97 ) wizard to create a delete button placed on a form.

The button works fine; however, When I click the button and select no to deleting the record, I get what appears to be a standard MS msgbox that says "The DoMenuItem was canceled.." and some other stuff that would probably confuse a user. It also sends you to the last record and since I am using the continuous forms view, if, for example, you have 3 records showing before you hit delete, now it looks like you only have 1! Of course, you can just hit the navigation button to bring them back, but this appears to me an unecessary potential confusion for the user (note, to get around this, I add some code under the "Exit_Command6_Click:
" code to go to the first record which solves this issue)..

My question is, how do I get rid of the MS Access generated message and insert my own more user friendly message if the user selects to cancel the delete request. Also, is there anywhere that shows what the instrinsic constant values refer to? 8 and 6 don't help much..

Thanks for any help..here is the code that the wizard generated..(with the exception of: DoCmd.GoToRecord acDataForm, "frm_view_assoc_rec", acFirst.

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command6_Click:
DoCmd.GoToRecord acDataForm, "frm_view_assoc_rec", acFirst
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub


I normally do not use the DoCmd.DoMenuItem methods since the can have issues between Access versions, etc.


Try:

Code:
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

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

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord

Exit_Command6_Click:
   '  DoCmd.GoToRecord acDataForm, "frm_view_assoc_rec", acFirst
    
    Me.[frm_view_assoc_rec].Requery

Exit Sub

Err_Command6_Click:
     If Err.Number = 2501 Then 
        MsgBox  "Your own message here"
     Else
        MsgBox Err.Description
     End if
     Resume Exit_Command6_Click

End Sub
 
You also wanted this:

Conquer Access RunCommand Constants
See the "DoMenuItem Conversion"

Hope this helps ...

Your code worked..:)

I looked up the above link, but there was nothing denoting the constant values for DoMenuItem. It appears, though, I should probably just use the Run Command as that does everything the DoMenuItem does and more?

Thanks for your help..
 

Users who are viewing this thread

Back
Top Bottom