Results 1 to 4 of 4
  1. #1
    mystifier is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    24

    Next Date Query

    Can anyone help with the following query to display the next appointment date:

    DATA
    Company, Frequency, Appointment
    ---------------------------------------
    CompanyA, 7, 1-Feb-2012
    CompanyA, 7, 8-Feb-2012
    CompanyA, 7, 15-Feb-2012
    CompanyB, 10, 1-Feb-2012


    CompanyB, 10, 11-Feb-2012
    CompanyB, 10, 21-Feb-2012
    CompanyC, 14, 1-Feb-2012
    CompanyC, 14, 15-Feb-2012

    RESULT
    CompanyA, 22-Feb-2012
    CompanyB, 02-Mar-2012
    CompanyC, 29-Feb-2012

    (i.e. Most recent Appointment + Frequency)

    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You should be able to use this to get the last record and the frequency:

    http://www.baldyweb.com/LastValue.htm

    In the second query, you can create a column with a DateAdd() using those two values.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mystifier is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    24
    Thanks Paul.

    If I had:
    SELECT MAX(Appointment) As LastAppointment FROM Table GROUP BY Company

    It worked fine but as soon as I added another field in broke. I would like to see how to handle it in one query but for now I can use two seperate queries as you suggest.

    Thanks for the response.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The first can be a subquery in the second, but I feel it's harder to work with that way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. query with date
    By nounou in forum Queries
    Replies: 8
    Last Post: 02-05-2012, 07:03 PM
  2. A date query
    By Andrias14 in forum Queries
    Replies: 15
    Last Post: 11-23-2011, 09:50 AM
  3. query to update a date based on another date
    By tkendell in forum Access
    Replies: 3
    Last Post: 06-29-2011, 09:32 PM
  4. Query on Date
    By niconic in forum Queries
    Replies: 2
    Last Post: 06-23-2011, 03:11 PM
  5. Replies: 2
    Last Post: 07-31-2009, 06:56 AM

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