Results 1 to 8 of 8
  1. #1
    tas6959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2022
    Posts
    4

    Query Results in Forms


    I am pulling in query results into MS Access from excel. The excel query is an Analysis for Office query tied to SAP. I built a query in access to pull in select fields I need from that linked excel spreadsheet. The query includes Item, Item Description and Sales date. I am pulling this data into a form. The issue I have is we are looking at rolling 12 month data. Every month the 12 months data shifts one month. When I pull the dates into the form, each field is date specific. If the most current month/year is Jul-22 and then next month the most current month is now Aug-22 which was not there when the form was built how do I make it so the form shows each of the 12 months in the query as it shifts one month every month?

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Show us please a screen shot of the form?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Use a calculation (expression) to subtract 12 months from either the current date or some provided date - whichever best suits your need. This should calculate a date 12 months prior to today
    dateadd("m",-12,date)

    Perhaps take a look at DateAdd function?
    EDIT - forgot to say your post isn't clear. 12 months prior to today, or from the 1st of the month that is 12 months ago? Probably the latter. Perhaps post your form sql.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    tas6959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2022
    Posts
    4
    Click image for larger version. 

Name:	Form Example.jpg 
Views:	16 
Size:	20.7 KB 
ID:	48571 Click image for larger version. 

Name:	Form Design View.jpg 
Views:	16 
Size:	83.3 KB 
ID:	48572

    The last date is 7/22...how do you make sure 8/22 will populate once the 12 month query is updated.

  5. #5
    tas6959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2022
    Posts
    4
    The months are not based on today. The query is updated once a month ends. This means that sometime in the first week after a month ends reporting is updated (let's say August just ended so the first week of September is the query update). The new query date range will be Sep-21 to Aug-22 (the prior query date range would have been Aug-21 to Jul-22).

  6. #6
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    That's what I thought, you are hardcoding the labels on the form .

    Replace the labels in the form's with text boxes and use something like Format(dMax("[YourDateField]","qryYourQuery"),"MMM YY") to get the latest, Format(DateAdd("m",-1,dMax("[YourDateField]","qryYourQuery")),"MMM YY") for the second to last, .... (or you can strat with dMin for the first one and keep adding positive 1 for each subsequent ones).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    tas6959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2022
    Posts
    4
    Perfect...thx!!!

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2019, 06:22 AM
  2. Replies: 4
    Last Post: 03-22-2019, 11:03 AM
  3. Replies: 2
    Last Post: 11-05-2014, 09:16 AM
  4. Replies: 6
    Last Post: 10-11-2012, 02:19 PM
  5. Combine queries results in forms
    By frasilvio in forum Queries
    Replies: 12
    Last Post: 01-10-2008, 01:34 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