By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,968 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,968 IT Pros & Developers. It's quick & easy.

Table with only the last record

P: n/a
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 ?

Feb 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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 ?

Feb 26 '06 #2

P: n/a

"solar" <sp*******@gmail.com> skrev i en meddelelse
news:11*********************@p10g2000cwp.googlegro ups.com...
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 ?


How about:

SELECT * INTO orders1 FROM orders WHERE orderid = (SELECT MAX(orderid) FROM
orders)

Feb 26 '06 #3

P: n/a
"Kaj Julius" <ju******@lindbjergparken.nospm.dk> wrote:

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
Feb 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.