Results 1 to 7 of 7
  1. #1
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129

    Criteria for last 12 months

    I have a report where I want to have two charts. So far I have one chart and a separate table showing stats for a specified time period. (I have a separate report form where dates are entered Normally monthly or quarterly). My first query in the datefield has this
    Between [Forms]![frmReports]![txtStartDate] And [Forms]![frmReports]![txtEndDate] All works well

    So now to my second chart, I want to display the last 12 months from my [textEndDate] and I want the months as Jan Feb etc and have tried quite a few combinations but i've reached my bestby date
    my last attempt was
    Between [Forms]![frmReports]!DateAdd("mmm",-12,[txtEndDate])And [Forms]![frmReports]![txtEndDate]
    help please

  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,640
    You don't want to break up the form reference like that. Try

    DateAdd("mmm",-12,[Forms]![frmReports]![txtEndDate])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129
    So are you saying the whole expression should be ?
    Between DateAdd("mmm",-12,[Forms]![frmReports]![txtEndDate]) And [Forms]![frmReports]![txtEndDate]
    because I get a message "Typed incorrectly or too long to be evaluated........try simplifying it" ?

  4. #4
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129
    Sorry I'm back on the phone so quickly, I'm having a brain fade over this lot. Now I do not need this expression in the query right? so long as my report has the two parts in text boxes with control source set to each part of the expression. However my first part < DateAdd("mmm",-12,[Forms]![frmReports]![txtEndDate])> comes up with name? on the report. meanwhile I have to look at my chart to try and get Feb Jan Mar into an order that is not alphabetical
    Thanks

  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,640
    Try with only 1 "m", which worked for me in a brief test. I would expect as the criteria of a query, though there could be other uses.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129
    Between DateAdd("m",-12,[Forms]![frmReports]![txtEndDate]) And [Forms]![frmReports]![txtEndDate]

    Yes this gives me the results I want in the query thankyou
    All I need to do now is translate that to the chart. I seem to find charts ddont always play the game especially when trying to get more than one chart and other info onto the same page of a report. ( I guess that is why there seem to be so many dashboard builder and similar around ??

    Thanks again

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Sorry, I don't do much charting. You might want to start a new thread on charting to get the attention of somebody with more experience in that area.
    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. Substracting months to a date
    By ruthib4 in forum Queries
    Replies: 2
    Last Post: 12-21-2011, 10:11 AM
  2. Counting Months
    By xzero1484 in forum Queries
    Replies: 1
    Last Post: 02-21-2011, 03:49 PM
  3. Query criteria, add 5 months to date
    By thart21 in forum Queries
    Replies: 1
    Last Post: 03-29-2010, 05:09 PM
  4. How to show all months
    By Brian62 in forum Queries
    Replies: 4
    Last Post: 10-20-2009, 08:55 AM
  5. A months query
    By Peljo in forum Access
    Replies: 1
    Last Post: 02-18-2008, 09:07 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