Results 1 to 6 of 6
  1. #1
    Sulaiman is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    3

    last entry in a field(Max) problem

    Hi All

    How do I get the last entry in a field.


    As I was reading the forums they said I should use the Max value it worked kinda but the problem is the corresponding amount banked is not the corresponding data to Max(date banked). How do I resolve the problem. How can I manipulate amount banked so it shows the correct values.
    SELECT DonorDetailsIndividual.DonorName, DonorDetailsIndividual.DonorSurname, DonorDetailsIndividual.Visitor, DonorHistoryIndividual.BankedAmount, Max(DonorHistoryIndividual.DateBanked) AS MaxOfDateBanked
    FROM DonorDetailsIndividual INNER JOIN DonorHistoryIndividual ON DonorDetailsIndividual.ID = DonorHistoryIndividual.ID
    GROUP BY DonorDetailsIndividual.DonorName, DonorDetailsIndividual.DonorSurname, DonorDetailsIndividual.Visitor
    HAVING (((DonorDetailsIndividual.Visitor)="Elections"));

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do this in a two-step process (either two queries, or a nested subquery).

    First query: Create an Aggregate Query to group the records and return the Max Date value.
    Second query: Link the first query to your original table (be sure to also include the Date field in your linking) to return the amount associated with that particular date.

  3. #3
    Sulaiman is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    3
    Quote Originally Posted by JoeM View Post
    Do this in a two-step process (either two queries, or a nested subquery).

    First query: Create an Aggregate Query to group the records and return the Max Date value.
    Second query: Link the first query to your original table (be sure to also include the Date field in your linking) to return the amount associated with that particular date.

    I am still having difficulty and the data still not correct.

    My problem is that I have three tables.
    I did groupby first and second table and made the third table last.
    In the second table I made the max (date) leaving the groupby amount banked.

    I then created a a second query with which table.Do I link it the new query table with table one as it is the parent table and must I link with the id.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    In the first query, you should NOT return the amount field at all. You just want to return the fields that you are grouping by, and the date field.
    The second query links back the amounts pertaining to the particular dates determined in the first query.

    If you still need help figuring it out, posting some small examples of your data tables and expected results may be helpful.

  5. #5
    Sulaiman is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    3
    test1.mdbHI

    I have attached some data. Still looking for the last AmountBanked and corresponding amount.

    It will be highly appreciative if you can help me.

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I was actually hoping for screen prints, rather than file attachments. From my current location, corporate policy prohibits me from downloading any files from the internet, for security reasons.

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

Similar Threads

  1. Data entry problem using subforms
    By Brobin in forum Forms
    Replies: 13
    Last Post: 02-22-2012, 03:26 PM
  2. Data Entry Problem
    By ZMac in forum Access
    Replies: 3
    Last Post: 06-15-2011, 08:15 PM
  3. Opening Form in Data Entry Mode Problem
    By alsoto in forum Forms
    Replies: 1
    Last Post: 05-28-2009, 07:45 PM
  4. Form Data Entry Problem?
    By corystemp in forum Database Design
    Replies: 1
    Last Post: 03-21-2009, 02:29 PM
  5. Report Detail Entry Selection Problem
    By Joe in forum Reports
    Replies: 0
    Last Post: 02-02-2009, 06:55 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