With the help of Hans, a member of the present Forum, i have built a sucessful function for deleting dates before a given value.
First i want to thank for the precious help i have received a lot from the Forum.My question now is how can i insert a constant in the function,
so as to make it more flexible.Mi idea is to have a constant :
And then replace it instead of the dates for example:
” WHERE (((orders.orderdate) <CnstBefore))" ' month,day,year
However, i receive the message "too few parameters".Can somebody explain why is it so?I am giving first the
successful function called "DeleteAllBefore" and then my effort to build the new function called "DeleteAllbefore1" which is not
working, and giving message "Too few parameters"
Public Const CnstBefore As Date = #6/1/2003#
Public Function DeleteAllBefore()
' month, day,year
Dim SqlRemoveFromOrders
Dim SqlRemoveFromOrderDetails
SqlRemoveFromOrders = "DELETE DISTINCTROW orders.orderdate AS Expr1 " & _
" FROM orders WHERE (((orders.orderdate)<#5/1/2003#));" ', month,day,year
SqlRemoveFromOrderDetails = " DELETE DISTINCTROW [order details].*, orders.orderdate " & _
"FROM orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID " & _
" WHERE (((orders.orderdate) <#5/1/2003#))" ' month,day,year
CurrentDb.Execute SqlRemoveFromOrderDetails
CurrentDb.Execute SqlRemoveFromOrders
End Function
Public Function DeleteAllBefore1()
' month, day,year
Dim SqlRemoveFromOrders
Dim SqlRemoveFromOrderDetails
SqlRemoveFromOrders = "DELETE DISTINCTROW orders.orderdate AS Expr1 " & _
" FROM orders WHERE (((orders.orderdate)<CnstBefore));" ', month,day,year
SqlRemoveFromOrderDetails = " DELETE DISTINCTROW [order details].*, orders.orderdate " & _
"FROM orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID " & _
" WHERE (((orders.orderdate) <CnstBefore))" ' month,day,year
CurrentDb.Execute SqlRemoveFromOrderDetails
CurrentDb.Execute SqlRemoveFromOrders
End Function