Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Table with only the last record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
solar - 26 Feb 2006 11:37 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.