Hello,
I have a continuous subform for Order Details. I want to have a "Delete" button next to each record, which deletes this record. I don't like the default record selectors.
I have this code:
However I get this error while executing the "DoCmd.RunCommand acCmdDeleteRecord":Code:Private Sub cmdDeleteItem_Click() DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True End Sub
Runtime error 2501: Run Command Action was canceled.
The same thing happens when I use the button wizard and tell it to delete the record (hence, using a macro).
Deleting the record like this works just fine:
(I connect to Microsoft SQL Server and execute the command there via ADO)
Can you please advise where might be the problem? Thank you.Code:Private Sub cmdDeleteItem_Click() Connect Exec "DELETE FROM tbl1PurchaseOrderDetails WHERE PurchaseOrderDetailID=" & Me.PurchaseOrderDetailID Disconnect End Sub
Tomas