View Full Version : DELETE SQL Deletes all rows


ScrmingWhisprs
04-03-2008, 04:09 PM
Hi there.

Could someone please tell me what I'm doing wrong? I have the following code for a command button, which is supposed to delete the row in a table that matches the ID number selected in a listbox:

Private Sub cmdRemoveQueue_Click()

Dim SQL As String
Dim bID As String

bID = Me.lboPrintQueue.Column(0)
SQL = "DELETE tblIDBatchPrint.bID " & _
"FROM tblIDBatchPrint " & _
"WHERE 'tblIDBatchPrint.bID = ' & bID;"


DoCmd.RunSQL SQL
Me.lboPrintQueue.Requery

End Sub

Instead of deleting that single row, it deletes everything in that table!!!

Please help!
Thanks
ScrmingWhisprs

RuralGuy
04-03-2008, 05:13 PM
Try:
SQL = "DELETE * FROM tblIDBatchPrint " & _
"WHERE tblIDBatchPrint.bID = " & bID & ";"
...assuming bID is a numeric value.

ScrmingWhisprs
04-03-2008, 05:37 PM
That did the trick!!!!!!!!

Many thanks!!!!!

RuralGuy
04-03-2008, 05:40 PM
Glad I could help.