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

Print a report where only the last record is choosen 1

Status
Not open for further replies.

Dophia

Technical User
Jul 26, 2004
263
CA
Hi Everyone: I have a one to many relationship. I want a report which prints only the last record of the many side. My data is as follows:

TblOne
ID_# (primary key, no duplicates)(One to many)
Other Info

TblTwo
AssessID (primary key) (autonumber)
ID_# (Primary key) (duplicates ok)(many to one)

So, TblTwo would have many records for a specific ID_#, but I only want the last AssessID to be printed. How can I do this automatically, without specifically choosing the latest AssessID for an ID_#?

Sophia
 
You can base your report on a query, for example:

Code:
SELECT tblOne.ID, Max(tblTwo.AssetID) As MaxOfID
FROM tblOne INNER JOIN tblTwo 
   ON tblOne.ID = tblTwo.ID
GROUP BY tblOne.ID



 

I don't know why this is working. Here is my actual data. Any help would be appreciated.

SELECT tblAnimals.Pound_Sheet_No, Max(tblAssessment_Details.AssessID) AS MaxOfAssessID
FROM tblAnimals RIGHT JOIN tblAssessment_Details ON tblAnimals.Pound_Sheet_No = tblAssessment_Details.Pound_Sheet_No
GROUP BY tblAnimals.Pound_Sheet_No;

Sophia
 
I meant to say "it is not working
 
Sorry, I spoke too soon. It does work!

Thank you Remou.

Sophia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top