I need to copy the tables orders and orderdetails containng only the
last order.I am copying them to another database using the formula
DoCmd.CopyObject db.Name, "orders", acTable, "orders"
DoCmd.CopyObject db.Name, "orderdetails", acTable, "orderdetails"
I want to use the criteria (SELECT Max([orderid]) FROM orders) in
order to send the tables with only the last order,but i do not know how
to build the code.Can you help me ?
solar - 26 Feb 2006 16:38 GMT
In addition to my question I guess that i should build a make table
query that contains only the last order.To this end i have tried to
build the following function:
Public Function Alan()
Dim SQL As String
SQL = "SELECT * INTO orders1 FROM orders WHERE orders1.orderid =
DMax(orderid,orders)"
CurrentDb.Execute SQL
End Function
However i get the error "too few parameters".Where am i wrong and i can
i do in that way ?
Kaj Julius - 26 Feb 2006 18:06 GMT
> In addition to my question I guess that i should build a make table
> query that contains only the last order.To this end i have tried to
[quoted text clipped - 8 lines]
> However i get the error "too few parameters".Where am i wrong and i can
> i do in that way ?
How about:
SELECT * INTO orders1 FROM orders WHERE orderid = (SELECT MAX(orderid) FROM
orders)
Mark - 26 Feb 2006 21:26 GMT
> How about:
>
> SELECT * INTO orders1 FROM orders WHERE orderid = (SELECT MAX(orderid)
> FROM orders)
Or use the spiffy "Top" operator that I just learned about on another
thread!
SELECT TOP 1 from orders ORDER BY orderid DESC