DELETE SQL Deletes all rows

ScrmingWhisprs

I <3 Coffee Milk.
Local time
Today, 16:36
Joined
Jun 29, 2006
Messages
156
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:

Code:
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
 
Try:
Code:
SQL = "DELETE * FROM tblIDBatchPrint " & _
          "WHERE tblIDBatchPrint.bID = " & bID & ";"
...assuming bID is a numeric value.
 
That did the trick!!!!!!!!

Many thanks!!!!!
 

Users who are viewing this thread

Back
Top Bottom