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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query - looking for the last record _ need help !!

Status
Not open for further replies.

budich

Programmer
Oct 7, 2000
79
ID
Does anyone knows how to make query for find records which are the last record. Let's me make an example :
I have database for transaction :
Transc _no Equipment_no Repair_date finish_rep
1 1000001 01/02/02 01/05/02
2 1000001 01/10/02 01/11/02
3 1000002 01/20/02 01/21/02
4 1000001 01/15/02 01/16/02
5 1000002 01/22/02 01/23/02

the example shows that equipment_no 1000001 has 3 times repair and I want make query to get only it's last transaction. So the query only show :
4 1000001 01/15/02 01/16/02
5 1000002 01/22/02 01/23/02

Would you please help me how to make this kind of criteria or what should I put in criteria rows in query ???
 
Construct a query containing only the Transc_no and Equipment_no fields, set this query to View Totals. Set the Transc_no field Total to 'Max' and the Equipment_no field to 'Group By'. Save this query as 'qryMaxTransc_no', which will produce the last Transc_no number for each Equipment_no.

Now construct a second query, pull in qryMaxTransc_no, that you have just created and your database table. Link the query to the table by 'MaxOfTransc_no to Transc_no' and 'Equipment_no to Equipment_no'. Display the contents of your table, this should produce the desired results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top