Results 1 to 4 of 4
  1. #1
    htmlasp is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    3

    Last row by month, for each month

    I have a table set up like:

    CUSTOMER ID / CUSTOMER NAME / PAYMENT ID / PAYMENT DATE

    Only want to show the last of each payment per month in form based on query.

    So if they have a payment in April of $900 on 4/15 and then a payment in May 5/2 $500 and May 15 $1000

    It will show two rows...one for April $900 payment and one for May $1000 payment.



    I know the logic is something like

    If more than one payment row for month, show last, otherwise only one payment for that month show the one payment

    HELP PLZ!

    I tried just setting hte "last" paramater but it only shows the very last payment, not taking month into account. So it only shows the $1000 may payment. thx

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    You want the last payment for each month for each customer?

    Try:

    SELECT CustomerName, Format(PaymentDate,"yyyymm") AS YrMo, Last(Payment) AS LastPay GROUP BY CustomerName, Format(PaymentDate,"yyyymm");

    However, Last and First functions can return unexpected results.

    Review: http://allenbrowne.com/subquery-01.html#TopN
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    htmlasp is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    3
    Hey June7,

    Yes that is what I'm looking for but one other issue: I need it not to be a read-only query becuase it is feeding into a form that I need users to add data to.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    You want only the one record for each month for each customer to be retrieved?

    Allen's TOP N nested subquery will be an editable recordset. I just tested it. Requires a unique identifier field. I used an autonumber.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-29-2014, 10:19 AM
  2. Replies: 4
    Last Post: 05-26-2013, 03:28 PM
  3. Month/Month to date
    By Tony McGuire in forum Queries
    Replies: 9
    Last Post: 09-20-2011, 11:54 AM
  4. Track capacity changes month by month
    By Nils in forum Database Design
    Replies: 1
    Last Post: 02-18-2011, 03:03 PM
  5. Replies: 5
    Last Post: 11-15-2010, 06:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums