Regarding Delete Button

cnuhima

Registered User.
Local time
Today, 09:27
Joined
Jun 19, 2008
Messages
72
Hi guys,

In the form i gave a command button for delete..But when i click on the delete button its not deleting the records and even not showing any error message..

With Regards,
HimaBIndu
 
Private Sub Delete_Click()
On Error GoTo Err_Delete_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Delete_Click:
Exit Sub
Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click
End Sub

yesterday when i was testing it worked..But i donot Know what is the problem with it...
 
This may sound dumb but check to see if under the button's click event " [Event Procedure]" is listed. There have been times when I accidentally deleted this which would cause nothing to happen when button clicked but would not delete code.

If it is there then put a breaking point to make sure your code is being executed.
 
try this

Dim question As String
question = MsgBox("Are you sure you want to delete these records" & vbCrLf & _
" this agreement ", vbYesNo + vbCritical, "Notice")
If question = 6 Then

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDelete
DoCmd.SetWarnings True
End If
 
Hi,

I tried using the above code also..Its showing the message but not not deleting the records..

Even I tried creating another delete button..Even then the problem is same..

Is there any option which i must have changed...

Thank you very much..

With Regards,
HimaBindu
 
Hi guys,


I got that.Here is the code:

Private Sub Delete_Click()
On Error GoTo Err_cmdDeleteRecord_Click

Me.Undo
DoCmd.RunCommand acCmdDeleteRecord

Exit_cmdDeleteRecord_Click:
Exit Sub

Err_cmdDeleteRecord_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteRecord_Click

End Sub

Thank you very much...

With Regards,
Himabindu.B
 
cnuhima,

Are you saying that you are not able to upload a copy of the database for us to diagnose? The code you posted appears to be valid on the face of it, but if it is not working for you, then it is possible that there is an underlying cause which would not be apparent to us without seeing the actual file.
 
Sorry,

I did not meanthat..when i was trying in differentways..i got this ..when i tried it works..Thats why i published it there..

Thank you very much..
 
Well, you've tried several valid codes for deleting a record without success. Barring some kind of corruption, my guess would be that you've got the form's AllowDeletions Propwerty set to No, either in code or in the Properties Pane.

This will keep records from being deleted but won't throw up any kind of error message.
 
Check the code behind the delete button, there might be some bugs crept in. Debug it for correct performance.
 

Users who are viewing this thread

Back
Top Bottom