Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dlete command does not delete (Access 2000)

    Could somebody tell me what is wrong with my delete commands? When clicking an order with the command
    CancelOrder(Me), i receive the message that 0 rows will be deletes but then the order remains undeleted.

    Public Function CancelOrder(frm As Form)
    Dim strSQL As String
    strSQL = "DELETE * FROM Orders WHERE orderID = " & frm!OrderID & ";"
    DoCmd.RunSQL strSQL
    strSQL = "DELETE * FROM [order details] WHERE orderID = " & frm!OrderID & ";"
    DoCmd.RunSQL strSQL
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: dlete command does not delete (Access 2000)

    If the message says that 0 rows will be deleted, it's not surprising that the order remains undeleted. Apparently, there are no reocrds that satisfy the WHERE condition.

    Some remarks:
    1. <LI>I assume that the database has a relation between Orders and Order Details on OrderID. If you have set relational integrity for this relation (you should!) and have set Cascading Deletes, deleting a record from Orders would also cause deletion of all related records in Order Details, so the second command would be superfluous. If you haven't set Cascading Deletes, you can't delete a record from Orders if there are related records in Order Details. In that case, you must delete the records from Order Details first, and then the record from Orders.
      <LI>Try inserting temporary instructions

      MsgBox strSQL

      immediately above the DoCmd.RunSQL strSQL instructions. Then you can see which OrderID is to be deleted. Perhaps the wrong number is passed.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: dlete command does not delete (Access 2000)

    1) the form represented by "frm" has to be open. Is it?
    2) Has the record you're trying to delete be *saved*? If it's a new record, then it hasn't.
    3) If OrderDetails is subordinate, delete those records first, then the Orders record.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •