Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133

    Limiting date ranges & aggregated query


    Hey guys, so we have a few reports that use ConcatRelated to fill data in a column on the report we are printing. We had to add a way to limit date ranges for the report instead of just printing reports for that month (time=NOW). I have followed the second instructional guide on here http://allenbrowne.com/casu-08.html I have filled in the script with my names and everything and when I press the button the report comes up but I get a "#Type!" in the concat related field and the rest are blank

    ConcatRelated:
    Code:
    =ConcatRelated("[condname]","reports","[cond] = '" & [cond] & "' And ([condemp]='Bree' Or [condemp]='Ben' Or [condemp]='Plumb' Or [condemp]='Lisa' Or [condemp]='Shaver' Or [condemp]='Smith' Or [condemp]='Julie')")
    I know the guide says that if you have a query that is behind the report as well it may not filter correctly, but I must find a way.

  2. #2
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    When I attempt the first step however the dialog boxes show but the reports still pulls up blank after entering the dates.

    Code:
    ((([reports].[timestamp])>=[StartDate])<[EndDate]+1))

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Put the 2 dates in a form for the query to read....

    Reports.timestamp between forms!myForm!txtStartdate and forms!myform!txtEndDate

  4. #4
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Query
    Code:
     (((reports.timestamp)) Between [Forms]![reportprint]![txtStart] And [Forms]![reportprint]![txtEnd]))
    ^SQL View
    Form
    Code:
    =[Forms]![reportprint]![txtStart]
    =[Forms]![reportprint]![txtEnd]
    ^Formatted to Short Date

    Report
    Code:
    =[Forms]![reportprint]![txtStart]
    =[Forms]![reportprint]![txtEnd]
    ^Formatted to Short Date

    I have the text boxes on the report and the form properly and removed the parameter prompt, however the text boxes in the form show #Error


  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You're saying the ConcatRelated function is returning the error? If the recordset in that function is being opened on the query, it can't resolve the form references. The simplest workaround is the Eval() function. Try

    reports.timestamp Between Eval("[Forms]![reportprint]![txtStart]") And Eval("[Forms]![reportprint]![txtEnd]")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    The error# is in the text boxes on the form itself in form view. I am trying this eval() now

  7. #7
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Code:
    SELECT reports.cond, Count(reports.cond) AS CountOfcond
    FROM reports
    WHERE (((reports.condemp)="name" Or (reports.condemp)="name" Or (reports.condemp)="name" Or (reports.condemp)="name" Or (reports.condemp)="name" Or (reports.condemp)="name" Or (reports.condemp)="name") And (((reports.timestamp)) Between Eval("[Forms]![reportprint]![txtStart]") And Eval("[Forms]![reportprint]![txtEnd]")))
    GROUP BY reports.cond;
    Now the report prints blank with this

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you use the actual names instead of "name"? If it printed appropriate records without the Eval() function, adding it shouldn't have changed what displayed on the report, just how the function used the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Yeah, I have to remove the names for privacy, when I click the button to bring up the report I get "Data type mismatch in criteria expression" followed by:

    Attachment 28035

    Then when I click the report again it appears blank.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Forbes View Post
    Yeah, I have to remove the names for privacy
    Better remove them from the first post then.

    So the query and report work without the Eval() function (except for the ConcatRelated textbox), and adding it throws the error?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Haha the first post is fictitious but I appreciate the lookout haha.

    I started with this
    (((reports.timestamp)) Between [Forms]![reportprint]![txtStart] And [Forms]![reportprint]![txtEnd]))
    but the report would just come up with no data

    then with
    (((reports.timestamp)) Between Eval("[Forms]![reportprint]![txtStart]") And Eval("[Forms]![reportprint]![txtEnd]")))
    it sends me the error, honestly I don't think any of the issues are related to concat but I just wanted to throw that information in the question in case, I know it has been giving us a lot of problems in the past.

  12. #12
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Code:
    AND (reports.timestamp Between Eval("[Forms]![reportprint]![txtStart]") And Eval("[Forms]![reportprint]![txtEnd]") ))
    GROUP BY reports.cond;
    I changed the data format on my database to match the short date so no more mismatch... however I still show ERROR# in the text boxes on the form
    Code:
    =[Forms]![reportprint]![txtStart]
    =[Forms]![reportprint]![txtEnd]

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The form is open? Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I can, I will need to do it tomorrow and the names conversion will take some time, so around tomorrow afternoon.

  15. #15
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Even after attempting to zip the file, the upload still will not take. Could you possibly pm me a junk email of yours I can send the compressed file too? Or offer a solution to my upload problems haha.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Date Between Ranges for SQL Query
    By BigSloppyJoes2000 in forum Queries
    Replies: 7
    Last Post: 02-13-2014, 05:09 PM
  2. Replies: 5
    Last Post: 12-12-2013, 12:14 PM
  3. Query for gaps in date ranges
    By kagoodwin13 in forum Queries
    Replies: 6
    Last Post: 03-19-2012, 07:00 PM
  4. Query return for date ranges.
    By Desstro in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 06:44 AM
  5. Select Query Using Different Date Ranges
    By Hemi426 in forum Queries
    Replies: 3
    Last Post: 07-26-2010, 01:06 PM

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