Results 1 to 4 of 4
  1. #1
    AAA is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    3

    Parameter date query displaying incorrect results

    I have a query with a calculated field that adds 1 year to a field called [TestDate]. Ex. Date Next Due: DateAdd("yyyy",1,[TestDate]). This works fine. Now I want to generate a parameter based on the calculated field "Date Next Due:". Ex. Between [Enter Start Date:] And [Enter End Date:]. Simple enough, however, the results are incorrect. In my screen captures below I am using a 6/1/15 - 6/30/15 date range. Note that when the query is run without the date parameter the result is 14 records. When it's run with the date parameter it's 11, however, all 6/4/15 records are missing and it added in a 6/1/16 record.

    Please help.

    Query without parameters:



    Click image for larger version. 

Name:	Dates without parameter.JPG 
Views:	13 
Size:	71.6 KB 
ID:	20776
    Query with parameters:
    Click image for larger version. 

Name:	dates with parameter.JPG 
Views:	13 
Size:	58.1 KB 
ID:	20777
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    How could any records be returned if there are no inputs to the parameter prompts? Very odd that the parameter inputs fail.

    I NEVER use dynamic parameterized queries and definitely do not use query popup prompts because cannot validate input. I use VBA to construct filter criteria and pass to form or report.

    Post the SQL statement of the parameterized query.
    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
    AAA is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    3
    SELECT Meters.[Meter#], Meters.Address, Meters.Size, Meters.City, [Accuracy Tests].TestDate, DateAdd("yyyy",1,[TestDate]) AS [Date Next Due]
    FROM Meters INNER JOIN [Accuracy Tests] ON Meters.[Meter#] = [Accuracy Tests].[Meter#]
    WHERE (((DateAdd("yyyy",1,[TestDate])) Between [Enter Start Date:] And [Enter End Date:]))
    ORDER BY DateAdd("yyyy",1,[TestDate]);

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Just did a test. The date parameters work on a native field but fail on the calculated field. Seems I've encountered this before. And this works:

    WHERE (((DateAdd("yyyy",1,[TestDate])) Between CDate([Enter Start Date:]) And CDate([Enter End Date:])))
    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. Date pass parameter incorrect
    By WickidWe in forum Forms
    Replies: 2
    Last Post: 01-09-2014, 09:14 PM
  2. Query from list box displaying incorrect values.
    By adammitchell23 in forum Queries
    Replies: 3
    Last Post: 11-28-2013, 12:54 PM
  3. Group by pulling incorrect results
    By jpawson74 in forum Queries
    Replies: 7
    Last Post: 03-28-2012, 09:46 AM
  4. Displaying query results in form
    By celito in forum Access
    Replies: 2
    Last Post: 08-27-2011, 09:14 AM
  5. Replies: 9
    Last Post: 12-13-2010, 09:25 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