Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Telling a query to return last 3 rows

Status
Not open for further replies.

justlearning2003

Technical User
May 26, 2003
34
CA
Hey everyone,

I have a query setup and I only want to return that last three rows of data from the table.
Anyone have any advice on how to set this up?
I am aware of the the SELECT TOP 3 but not sure if it is possible to just bring back the last 3 records.

Thanks
 
try setting your sort order to Descending (or the opposite of you current sort order) and then select the Top 3.

hope this helps.
 
Probly not the best way, but this code will make a second table with the last 3 records and you can query that

sub writetable ()
dim db as database
dim rst1 as recordset
dim rst2 as recordset

dim count as interger

set db as currentdb
set rst1 = db.openrecordset("select * from Table1Name")
set rst2 = db.openrecordset("select * from Table2Name")
rst1.movelast
rst1.moveprevious
rst1.moveprevious

for count = 0 to 2
with rst1
.addnew
rst2!fieldname = !fieldname
.update
next count
end Sub

Durible Outer Casing to Prevent Fall-Apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top