473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Table with only the last record

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
3 1284
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

"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am...
2
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml...
2
by: Tony Williams | last post by:
I have two tables one lists the names of committees and the other is a list of documents they generate. I have a form based on the documents table which gives details of the document including...
1
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to use a make table query to pull the last transactionID, so I can use an append query to reset the transactionID to the next...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
10
by: Regnab | last post by:
I'm making a database to record training that employees have recieved. For each training excercise, they recieve a mark between 1 and 3. Initially, when there weren't so many training elements, I...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
2
klarae99
by: klarae99 | last post by:
Hello, I am working in Access 2003 to create a database to record information about an annual fundraiser. I was hoping someone could review my table structure and make sure that it is normalized...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.