Results 1 to 2 of 2
  1. #1
    Mo2783 is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Location
    UK
    Posts
    1

    Next 14 Dates Required

    Hi all

    I hope someone can help, i am trying to get information from 2 tables.

    i have a table with Test Information has the date of test field, and another table holds results with a field called ResObtained.

    What the user does is enter a date and then the query needs to return the next 14 dates. so for example if the user selected 15/07/2009 then the query will return the next 14 days where it has the data.



    example

    user selects 15/07/2009

    then the query needs to return the next 14 dates, which could be like this

    16/07/2009
    19/07/2009
    20/07/2009
    21/07/2009
    24/07/2009
    29/07/2009
    02/08/2009
    07/08/2009
    10/08/2009
    11/08/2009
    13/08/2009
    14/08/2009
    15/08/2009

    The results obtained table will hold information like A,A,A+ B,B+ etc.

    So a date can have many results. i need to get information where a user selects the date and the next 14 results that are displayed where the results are A regardless of whats after that.

    i have the follwoing query
    Code:
    SELECT Results.Result, Test.TestDate AS Isdate
    FROM Results INNER JOIN Test ON Results.ResultNumber = Sample.ResultNumber
    WHERE (((Results.Result) Like "*A*") AND ((Sample.TestDate) Between [Enter Date] And DateAdd("d",14,[Enter Date])));

    Any help would be appreciated.

    Thanks.
    Last edited by Mo2783; 02-28-2011 at 10:40 AM. Reason: Add the query

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I'm not sure I totally understand what you are after, so please clarify if the approach I suggest doesn't provide a solution.

    The WHERE clause of your query restricts the dates between the date entered and 14 days from the date entered. This will not guarantee that you will get the next 14 dates. You might get less or you might get more.

    What I would do is to find all of the dates greater than or equal to the date entered and then use another query to get the 14.

    First, modify your current query as follows. Please note that I changed the Isdate alias to myDate. Isdate() is a function in Access, so you should not use the same name; it may cause problems.

    Code:
    SELECT Results.Result, Test.TestDate AS myDate
    FROM Results INNER JOIN Test ON Results.ResultNumber = Sample.ResultNumber
    WHERE (Results.Result Like "*A*") AND (Sample.TestDate >=[Enter Date]) 
    ORDER by Testdate desc
    Then create this query based on the query above
    Code:
    SELECT TOP 14 Results.Result, Mydate
    FROM nameofqueryabove

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

Similar Threads

  1. Dates
    By talisman in forum Programming
    Replies: 1
    Last Post: 02-25-2011, 11:42 AM
  2. display all dates between two dates
    By KenThompson in forum Access
    Replies: 8
    Last Post: 02-23-2011, 01:11 PM
  3. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 PM
  4. Dates
    By spqr in forum Queries
    Replies: 4
    Last Post: 09-28-2010, 02:33 PM
  5. Between dates using Iif
    By unique in forum Access
    Replies: 1
    Last Post: 01-04-2010, 07:17 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