Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Modifying Delete Button code

Geek News

Modifying Delete Button code
Mishanya 12/24/2008 2:14:04 PM
In my form I have Delete Button coded by the wizard with some modification as
follows:

Private Sub btnDeleteAsset_Click()
On Error GoTo Err_btnDeleteAsset_Click

If MsgBox("Are You sure You want to delete this asset?", _
vbYesNo + vbExclamation, "Attention!") = vbNo Then
Me.Undo
Cancel = True

Else

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "The deletion is completed"

Exit_btnDeleteAsset_Click:
Exit Sub

Err_btnDeleteAsset_Click:
MsgBox "Your deletion attempt is aborted"
Resume Exit_btnDeleteAsset_Click

End If

End Sub

The events caused by pressing the button go as this:
1) My message "Are You sure You want to delete this asset?"

if NO selected - this is it

if YES selected
2) Access message box "You are about to delete 1 record", while the record
I'm trying to delete is changed by the next record

if NO selected
3) My message "Your deletion attempt is aborted", while the recordset is
back to the attempted

if YES selected
3) My message "The deletion attempt is completed"

The step 2) is quite confusing - firstly, it doubles my message, secondly -
next record is already presented, wich makes the user hesitate what is he
about to delete.

How can I modify the code so the whole thing will work properly:
1) no Access messages but defined by me
2) no next record popping up in the step 2 (ideally - I still see the
attempted record)
3) after the deletion is completed the form is in New record mode (again, no
next record popping up)?


Re: Modifying Delete Button code
"ErezM via AccessMonster.com" <u45095[ at ]uwe> 12/24/2008 8:23:45 PM
hi
to remove the access built in alerts for deletion andqor change, in
access<2007, go to tools->Options, switch to "edit" tab, there you'll see a
group of 3 checkboxes titled "Confirm". if you remove the checks from the
checkboxes, access will not confirm the un-checked actions - which is what
you're looking for

for deletion of the current record on a form, i use "DoCmd.RunCommand
acCmdDeleteRecord", and i dont know what the 2 commands you wrote are doing

since the button is just a command button (and not the delete key on the
keyboard, for example), there is no need to undo or cancel anything, you just
dont perform the delete

hope it helps
Erez

Mishanya wrote:
[Quoted Text]
>In my form I have Delete Button coded by the wizard with some modification as
>follows:
>
>Private Sub btnDeleteAsset_Click()
>On Error GoTo Err_btnDeleteAsset_Click
>
>If MsgBox("Are You sure You want to delete this asset?", _
> vbYesNo + vbExclamation, "Attention!") = vbNo Then
> Me.Undo
> Cancel = True
>
>Else
>
> DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
> DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
> MsgBox "The deletion is completed"
>
>Exit_btnDeleteAsset_Click:
> Exit Sub
>
>Err_btnDeleteAsset_Click:
> MsgBox "Your deletion attempt is aborted"
> Resume Exit_btnDeleteAsset_Click
>
>End If
>
>End Sub
>
>The events caused by pressing the button go as this:
>1) My message "Are You sure You want to delete this asset?"
>
>if NO selected - this is it
>
>if YES selected
>2) Access message box "You are about to delete 1 record", while the record
>I'm trying to delete is changed by the next record
>
>if NO selected
>3) My message "Your deletion attempt is aborted", while the recordset is
>back to the attempted
>
>if YES selected
>3) My message "The deletion attempt is completed"
>
>The step 2) is quite confusing - firstly, it doubles my message, secondly -
>next record is already presented, wich makes the user hesitate what is he
>about to delete.
>
>How can I modify the code so the whole thing will work properly:
>1) no Access messages but defined by me
>2) no next record popping up in the step 2 (ideally - I still see the
>attempted record)
>3) after the deletion is completed the form is in New record mode (again, no
>next record popping up)?

--
May all beings be happy.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: Modifying Delete Button code
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> 12/25/2008 10:56:54 AM
You didn't see or didn't like the response i posted?

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net