Picking only the latest entry?

  • Thread starter Pascoe via AccessMonster.com
  • Start date
P

Pascoe via AccessMonster.com

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.
 
J

Jeff Boyce

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.
 
P

Pascoe via AccessMonster.com

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 said:
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.
 
P

Pascoe via AccessMonster.com

Bumping this back up!

Hoping for a reply!
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.
[quoted text clipped - 22 lines]
 
K

KenSheridan via AccessMonster.com

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
Bumping this back up!

Hoping for a reply!
[quoted text clipped - 11 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top