Results 1 to 2 of 2
  1. #1
    paul.holness is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    5

    Sumproduct

    The client db is not Normalized. I understand their requirements and the current table structure has to remain in tact. The DATA ENTRY staff need to enter cost for Jan1 to Jun30. One of the many calculations that needs to be updated daily is the SUMPRODUCT from STARTDATE to ENDDATE - which can be anywhere between Jan1 to Jun30 at any time. The example scenario below needs to calculate the sumproduct of COST between any two fields (days of week).

    For example, let's say a Purchase Order has been created, and the initial entry looks like this:


    StartDate = Jan30
    End Date = Jun3
    Jan1 thr Jan29 Cost = 0
    Jan30 Jun3 Cost = 500 (average daily burn rate)
    Jun4 thr Jun30 Cost = 0

    ... and the staff receives and update to the daily spread. The Cost Spread between Jan1 to Jun30 NOW looks like this:
    StartDate = Jan15
    End Date = Jun3
    Jan1 thr Jan14 Cost = 0
    Jan15 thr Mar29 Cost = 1000
    Mar30 thr Jun2 Cost = 3000
    Jun3 thr Jun3 Cost = 500
    Jun4 thr Jun30 Cost = 0

    Here is the code I am using to calc the SumProduct upon initial entry WHERE the 'average daily burn rate' for the entire spread is the same every day (FYI, we need to calculate the YearTo-Date (YTD) and Remaining Balance from YTD for both Commitment and Incurred cost. For this example I am only snipping the code here to reflect Incurred)
    'Initial Calculations
    If CurrentDate <= frmStartDate Then
    SUMPRODUCTYTDIncurred = ZeroValue
    Else
    SUMPRODUCTYTDIncurred = Round((DailyBurnRate + DailyBurnRate * NoDays), 2)
    End If
    If CurrentDate <= frmStartDate Then
    SUMPRODUCTRemainingIncurred = ZeroValue
    Else
    SUMPRODUCTRemainingIncurred = Round(DailyBurnRate + DailyBurnRate * (DateDiff("d", CurrentDate, frmEndDate)), 2)
    End If

    In my UPDATE SCRIPT (not shown - cause its TMI):
    - I am using the For Each statement to search an ARRAY to filter for the db.TableDefs("MYTABLE").Fields I need to update.
    - I am also using a Do While True statement to catch the cost for the found field.

    How to catch all the cost between Jan1 to Jun30 before updating the SUMPRODUCT field and then .MoveNext until EOF (remembering that the For Each statement will stop when field Jun30 is found)?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538

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

Similar Threads

  1. Replies: 9
    Last Post: 05-30-2012, 01:23 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