Results 1 to 2 of 2
  1. #1
    csamy987 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Posts
    1

    Dsum with Dynamic Date

    Hi,

    I have a source forecast table with the account number and material number as fields, the actual forecast is listed by field names corresponding to their month and year.
    ie.
    Account #, Material#, 20183, 20184, 20185
    3456 1234 3 2 6
    7891 2345 2 3 7

    I have a working table where I have the account # and material # listed as fields also but I'm trying to pull the addition of the next three months in the forecast.
    It looks like this
    Account#, Material#, next 3 month forecast
    3456 1234 11


    7891 2345 12

    Right now I have an update query to update the [next3MonthForecast] field by updating to [20183]+[20184]+[20185] which it works but how can I make it dynamic? I don't want to be changing this every month. I have tried [Year(Date())&Month(Date()))] within each bracket (adding 1 for the next month and so on) but it does not work.

    I have also tried using a Dsum with the criteria being " [cfield]= 'Year(Date())&Month(Date())' " but again, it does not work. Any help will be appreciated.

    Thanks,

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The table would look like: (use real dates)
    [date],[acct],[material]
    3/1/18, 3456, 1234 11
    4/1/18, 3456, 1234 11

    then on a form, use a text box to enter the date you want, (txtStartDate)
    put another text box,(txtDate3) to calculate the 3 months ahead: = dateadd("m",3,txtStartDate)

    then the query will pull 3 months in future.
    select * from table where [date] between forms!myForm!txtStartDate and forms!myForm!txtDate3

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

Similar Threads

  1. MS Access Date Variables in Dsum
    By David Randle in forum Programming
    Replies: 3
    Last Post: 10-08-2016, 08:11 PM
  2. Use the Date as a criteria in Dsum function
    By Ank_db in forum Queries
    Replies: 1
    Last Post: 01-18-2015, 12:08 PM
  3. How to Format Date parameter in Dsum
    By misahil in forum Queries
    Replies: 3
    Last Post: 09-28-2014, 11:31 AM
  4. DSum with Dynamic Range
    By Kimbertha in forum Queries
    Replies: 15
    Last Post: 11-05-2010, 11:47 AM
  5. DSUM with date criteria from form
    By krutoigoga in forum Reports
    Replies: 4
    Last Post: 07-28-2010, 01:32 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