gselliott
09-04-2003, 06:03 AM
I am having problems deleting a current record using VB Code.
I am able to delete it however i dont want the message box that lets the user select Yes or No, i just want it to delete it without asking or use the OK button.
Is there anyway of doing this? Any help would be appreciated.
Thanks
dcx693
09-04-2003, 06:18 AM
Haven't tried it myself, but have you tried:
DoCmd.SetWarnings False
Or deleting the record using SQL?
gselliott
09-04-2003, 06:25 AM
Cheers the Docmd.SetWarnings False worked a treat!
ghudson
09-04-2003, 01:26 PM
Just in case the user clicks the button by mistake... Are you sure that you do
not want to give the user the choice if they want to delete the current record?Private Sub bDelete_Click()
On Error GoTo Err_bDelete_Click
Beep
If MsgBox("Are you sure you want to delete the current record?", vbQuestion + vbYesNo, "Delete Current Record?") = vbYes Then
DoCmd.Setwarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Setwarnings True
End If
Exit_bDelete_Click:
Exit Sub
Err_bDelete_Click:
If Err = 2046 Then 'The command DeleteRecord isn't available now - No records to delete
Beep
MsgBox "There is no record to delete.", vbCritical, "Invalid Delete Request"
Exit Sub
ElseIf Err = 2501 Then 'The RunCommand action was canceled
Exit Sub
Else
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bDelete_Click
End If
End Sub
Adding some fields to the message box so that you are identifying some parts of the
current record is also a nice touch for the user to see.
HTH
dream
09-04-2003, 06:15 PM
Great I'm also looking for this.. What if my delete is in the form then i attach a subtable to it, how would i delete the selected record on the table? Sorrie to interupt...