Results 1 to 5 of 5
  1. #1
    keith2511 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Location
    UK
    Posts
    45

    Crosstab query prompts seven times for date range

    I have a crosstab query that takes the start and end date parameters from a form. This form is used in several other queries [which work perfectly] but the one below prompts the user for the date range seven times. The parameter definitions are the same in each query. The one difference between this and my other queries is that this is grouping by month, while others are grouping on different fields. Any idea why there are several prompts for the date range?
    Thanks
    Code:
     PARAMETERS [Forms]![Date_Range]![Start_Date] DateTime, [Forms]![Date_Range]![End_Date] DateTime;TRANSFORM Round(Sum([Total_Net]),2) AS Expr2
    SELECT [All_Invoices_18-19].Supplier, Sum([All_Invoices_18-19].Total_Net) AS [Total Of Total_Net]
    FROM [All_Invoices_18-19]
    WHERE (((Format([Invoice_Date],"yyyy/mm")) Between [Forms].[Date_Range].[Start_Date] And [Forms].[Date_Range].[End_Date]))
    GROUP BY [All_Invoices_18-19].Supplier
    PIVOT Format([Invoice_Date],"yyyy/mm");


  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Potentially stupid question, is the form open when the query runs? I don't see offhand why it would prompt if so, particularly 7 times. That's just opening the query, not a form/report based on the query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    might have something to do with the fact you have [Forms]![Date_Range]![Start_Date] in the parameters and [Forms].[Date_Range].[Start_Date] in the criteria (bang and dot)

    also be surprised if the criteria works anyway

    WHERE (((Format([Invoice_Date],"yyyy/mm")) Between [Forms].[Date_Range].[Start_Date] And [Forms].[Date_Range].[End_Date]))
    you are comparing a string with a date

    would think it needs to be

    WHERE ((([Invoice_Date]) Between [Forms].[Date_Range].[Start_Date] And [Forms].[Date_Range].[End_Date]))

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Arg, I missed the bang v dot.

    I assume the user enters an appropriate string on the form, since the same method works in other queries. Don't like the method since it requires the function to be applied to every record in the table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    keith2511 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Location
    UK
    Posts
    45
    Thanks Ajax, that has worked.

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

Similar Threads

  1. Replies: 17
    Last Post: 07-31-2018, 01:23 PM
  2. Run a previously created Multiple times for a date range
    By unreal_event_horizon in forum Programming
    Replies: 3
    Last Post: 08-29-2014, 09:06 AM
  3. Replies: 1
    Last Post: 07-14-2014, 10:45 PM
  4. Replies: 3
    Last Post: 03-11-2014, 07:32 PM
  5. Crosstab query with date range (2 years)
    By Cassim in forum Queries
    Replies: 7
    Last Post: 11-11-2013, 08:48 AM

Tags for this Thread

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