![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
Hi Folks,
I want to pick out of a table only the latest entry that meets my criteria, and I don't know how to. I have properties (as a table), and I have property expenses (also as a table) . I would like to display a report where for each property there is the latest entry for electric bill, latest entry for gas bill, latest entry for service charge etc. i.e. the criteria is bill = electric, date = most recent I am at a loss as to how to go about the instruction for "most recent" entry. As ever, any help gratefully received. Kind Regards, Russell. -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
![]()
Russell
Access stores data in tables rather like a "bucket o' data" -- there is no readily-apparent order. For Access to give you "the latest entry" requires that you tell Access how to determine what "latest" means. I'm assuming you mean "most recent". If so, you'll need to tell Access which (date/time) field to use to determine "most recent". You mention "bills" on properties ... are you only interested in when the bill came in, or also when it is/was due, when it was paid, etc...? More info, please... Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. You can thank the FTC of the USA for making this disclaimer possible/necessary. "Pascoe via AccessMonster.com" u43716@uwe wrote in message news:a8a2fdf02a983@uwe... Hi Folks, I want to pick out of a table only the latest entry that meets my criteria, and I don't know how to. I have properties (as a table), and I have property expenses (also as a table) I would like to display a report where for each property there is the latest entry for electric bill, latest entry for gas bill, latest entry for service charge etc. i.e. the criteria is bill = electric, date = most recent I am at a loss as to how to go about the instruction for "most recent" entry. As ever, any help gratefully received. Kind Regards, Russell. -- Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
![]()
Jeff,
Thanks for your reply. We store the bills with one date on them, and it is that date that I will use to monitor the "most recent" bill. Kind Regards, Russell. Jeff Boyce wrote: Russell Access stores data in tables rather like a "bucket o' data" -- there is no readily-apparent order. For Access to give you "the latest entry" requires that you tell Access how to determine what "latest" means. I'm assuming you mean "most recent". If so, you'll need to tell Access which (date/time) field to use to determine "most recent". You mention "bills" on properties ... are you only interested in when the bill came in, or also when it is/was due, when it was paid, etc...? More info, please... Regards Jeff Boyce Microsoft Access MVP Hi Folks, [quoted text clipped - 17 lines] Kind Regards, Russell. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201005/1 |
#4
|
|||
|
|||
![]()
Bumping this back up!
Hoping for a reply! Pascoe wrote: Jeff, Thanks for your reply. We store the bills with one date on them, and it is that date that I will use to monitor the "most recent" bill. Kind Regards, Russell. Russell [quoted text clipped - 22 lines] Kind Regards, Russell. -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
![]()
You can restrict the query by means of a subquery which returns the latest
(MAX) date per property/bill, e.g. SELECT Property, Bill, BillDate, Amount FROM Properties INNER JOIN Expenses AS E1 ON Properties.PropertyID = E1.PropertyID WHERE BillDate = (SELECT MAX(Billdate) FROM Expenses AS E2 WHERE E2.PropertyID = E1.PropertyID AND E2.Bill =E1.Bill) ORDER BY Property, Bill; The two instances of the Expenses table are differentiated by the aliases E1 and E2, enabling the subquery to be correlated with the outer query. Ken Sheridan Stafford, England Pascoe wrote: Bumping this back up! Hoping for a reply! Jeff, [quoted text clipped - 11 lines] Kind Regards, Russell. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201006/1 |
Thread Tools | |
Display Modes | |
|
|