Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code does not function (Access 2000)

    Why is my code not working?

    I have a code to delete records before a given date which used to work before in other situation.But now i am trying it on the OnClick event,
    nothing happens,i receive no message for error, but the data in the tables are not deleted.I am very puzzled. Whata might be the cause?

    Private Sub Command1_Click()
    Dim SqlRemoveFromOrders
    Dim SqlRemoveFromOrderDetails
    SqlRemoveFromOrders = " DELETE DISTINCTROW orders.orderdate AS Expr1 " & _ " FROM orders " & _ " WHERE (((orders.orderdate)<#1/1/2004#));"
    SqlRemoveFromOrderDetails = " DELETE DISTINCTROW [order details].*, orders.orderdate " & _ "FROM orders INNER JOIN [order details] ON orders.orderid =

    [order details].OrderID " & _
    " WHERE (((orders.orderdate) <#1/1/2004#))"
    CurrentDb.Execute SqlRemoveFromOrders
    CurrentDb.Execute SqlRemoveFromOrders

    End Sub

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

    Re: Code does not function (Access 2000)

    You're executing the same SQL twice:

    CurrentDb.Execute SqlRemoveFromOrders
    CurrentDb.Execute SqlRemoveFromOrders

    That should be

    CurrentDb.Execute SqlRemoveFromOrderDetails
    CurrentDb.Execute SqlRemoveFromOrders

Posting Permissions

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