A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete not working in Access 2007



 
 
Thread Tools Display Modes
  #1  
Old May 3rd, 2010, 11:42 AM posted to microsoft.public.access.forms
Bob H[_4_]
external usenet poster
 
Posts: 161
Default Delete not working in Access 2007

I have been running a Acess 2007 database on a server for about 15
months, and now I want to delete certain records form it using the
cmdDelete button which has this code behind it:

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

Select Case MsgBox("Are you ure you want to delete this record?", vbYesNo)
Case vbYes 'Do nothing: it saves by default.
Case vbNo 'Undo the changes, and close.


End Select
Exit_Save_Click:
Exit Sub

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click

End Sub

I have found that the records are not deleted when I click the button,
so what am I missing here.

Thanks
  #2  
Old May 3rd, 2010, 12:49 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Delete not working in Access 2007

For one thing, you are exiting the sub before deleting the record (at
Exit_Save_Click, which is not the current sub, but Access will run the Exit
Sub routine anyhow, I think. Also, the message box does nothing. The user
can click Yes or No, but you exit the sub in either case. Alternatively, if
you leave out the Exit Sub line at Exit_Save_Click, the record will be
deleted no matter what the user selects for Yes or No.

Bob H wrote:
I have been running a Acess 2007 database on a server for about 15
months, and now I want to delete certain records form it using the
cmdDelete button which has this code behind it:

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

Select Case MsgBox("Are you ure you want to delete this record?", vbYesNo)
Case vbYes 'Do nothing: it saves by default.
Case vbNo 'Undo the changes, and close.

End Select
Exit_Save_Click:
Exit Sub

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click

End Sub

I have found that the records are not deleted when I click the button,
so what am I missing here.

Thanks


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.