Deleting A Record

bossmack916

New member
Local time
Today, 09:29
Joined
Mar 28, 2012
Messages
6
I need some assistance in deleting a record from a table using a command button. I am preety new to coding within Access, but can understand code better than I can produce it. Im not familiar with all of the syntax.

With that said, here is what i have so far. I am trying to run a docmd.RunSQL command to do a DELETE statement:

Private Sub Command40_Click()

DoCmd.RunSQL(Delete * FROM Products WHERE txtProductRowID = me.txtProductRowID)

End Sub

Theres is basically a form with product information based on the product ID. I want to delete the product from the "Products" Table because it is no longer a product they carry. So with the press of this button I would like all of the information deleted from the table and form.....

Your assistance is greatly appreciated!
 
Try

CurrentDb.Execute "Delete * FROM Products WHERE txtProductRowID = " & me.txtProductRowID, dbFailOnError

The Execute method has advantages over RunSQL.
 
Just out of curiosity, why use SQL instead of a simple

DoCmd.RunCommand acCmdDeleteRecord

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom