Results 1 to 3 of 3
  1. #1
    valglad is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2017
    Posts
    5

    Missing Dates - Running Balance


    Hello,

    I need help on how to deal with identifying missing dates, creating new records and assigning values to them.

    The data looks like that:

    Account_Number----------Currency-----------PostingDate--------OpeningBalance-----NetDaily---------Closing Balance
    1234-------------------------USD--------------July 1, 2016----------$80-----------------+$20-----------------$100
    1234-------------------------USD--------------July 3, 2016----------$100----------------+$40-----------------$140
    1234-------------------------USD--------------July 4, 2016----------$120----------------+$10-----------------$130
    1234-------------------------SGD--------------July 1, 2016----------$160-----------------$5-------------------$155
    1234-------------------------SGD--------------July 7, 2016----------$180----------------+$0------------------$180
    1235-------------------------USD--------------July 1, 2016----------$100---------------+$10------------------$110
    1235-------------------------USD--------------July 3, 2016-----------$10------------------$5-------------------$5

    So, the objective is - if a date for the Acc Number/Currency combination is missing - to create a new record (i.e. for 1234-USD for July 2, 2016) and assign the closing balance from July 1 to the opening balance of the newly created record ($100), put zero for the NetDaily and put the sum of the Opening plus NetDaily into closing ($100+$0, or simply $100 since there was no activity that day).

    The time gap could be up to two weeks. The data is sent by individual banks in csv format and is uploaded nightly into the database. The banks are located in different countries and operate on their own schedules. If the bank is closed, there is no report.

    A query based on the table feeds an excel spreadsheet via pivot table and displays a cash position per day. Since some dates are missing for some combos of (Acc Num, Curr) - the opening balance, Net daily and the closing balance display NULL. To make the report uniform I need the data to have all elements for all days.

    I did google different resources and ask some other forums but no results so far. So, if anyone can help - that would be really great.

    Thanks
    Valeri

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    i answered this on the other board. It has code to cycle thru a calendar, adding EVERY date to a table,
    then use that table in an outer join to build the missing dates.

  3. #3
    valglad is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2017
    Posts
    5
    Thank you. But my problem is bigger than just identifying the dates. That part is easy, it's assigning values to the new records that I have the problem with, especially if the sequence of the missing dates is more than one.

    Btw, in your code, vStart needs a datevalue function around the expression because otherwise it a string.
    sub buildDates(pvMo, pvYr)
    dim vDate, vStart, vEnd


    docmd.setwarning false
    vStart = pvMo & "/1/" & pvyr
    vEnd = dateAdd("d",-1,dateAdd("m",1,vStart))
    vDate = vStart

    while vDate < vEnd
    sSql = "insert into tMonthDates ([Date]) values (#" & vDate & "#)"
    docmd.runSql sSql
    vDate = dateAdd("d",1,vDate)
    wend
    end sub

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

Similar Threads

  1. How To Get Running Balance Of Customer with last balance
    By muhammadirfanghori in forum Access
    Replies: 1
    Last Post: 10-25-2016, 03:31 PM
  2. General Ledger Query With Opening Balance and Running Balance
    By muhammadirfanghori in forum Queries
    Replies: 3
    Last Post: 03-12-2015, 07:17 AM
  3. Running Balance in forms or queries
    By Windward in forum Access
    Replies: 7
    Last Post: 02-17-2012, 02:40 PM
  4. Running balance
    By bka57 in forum Forms
    Replies: 3
    Last Post: 01-22-2012, 07:05 PM
  5. Running balance in a form
    By Ray67 in forum Forms
    Replies: 5
    Last Post: 10-24-2011, 07:43 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