Results 1 to 4 of 4
  1. #1
    accessbro is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    23

    Calculating field based on value of another field in previous record

    I'm trying to create something like an online banking view that shows the running balance as each transaction occurs. I have tblTransactions with fields AccountNumber, ItemDescription, and TransactionAmount. I'm trying to create something that shows these three fields and a fourth field with the running balance. So if I initially deposit $100 it will show the first record with TransactionAmount = $100 and RunningBalance = $100. Then the next transaction will subtract the Transactionamount for the new record from the RunningBalance from the previous record to get the RunningBalance for the new record. So if I make a purchase for $2, the AvailableBalance for that record is $98. Is this possible with a query? Here's a picture to describe what I'm talking about:



  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Not easy in query or form. Review http://allenbrowne.com/subquery-01.html#AnotherRecord

    Textbox on report has a RunningSum property that might serve.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    use the dsum function.

    simple eg.

    table1
    id - autonum
    amt - num
    tran - num (1 or -1 debit/credit)

    create a query, the runing sum col will be;
    run_sum: DSum("amt*tran","Table1","id<=" & [id])

    read the criteria part carefully.


    since my data is in order of entry, i'm using the id field.Click image for larger version. 

Name:	tbl1.jpg 
Views:	18 
Size:	23.9 KB 
ID:	18149

    Click image for larger version. 

Name:	qry2.jpg 
Views:	18 
Size:	51.1 KB 
ID:	18148

    and the result Click image for larger version. 

Name:	results.jpg 
Views:	18 
Size:	22.1 KB 
ID:	18147

  4. #4
    accessbro is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    23
    Quote Originally Posted by qa12dx View Post
    use the dsum function.

    simple eg.

    table1
    id - autonum
    amt - num
    tran - num (1 or -1 debit/credit)

    create a query, the runing sum col will be;
    run_sum: DSum("amt*tran","Table1","id<=" & [id])

    read the criteria part carefully.


    since my data is in order of entry, i'm using the id field.Click image for larger version. 

Name:	tbl1.jpg 
Views:	18 
Size:	23.9 KB 
ID:	18149

    Click image for larger version. 

Name:	qry2.jpg 
Views:	18 
Size:	51.1 KB 
ID:	18148

    and the result Click image for larger version. 

Name:	results.jpg 
Views:	18 
Size:	22.1 KB 
ID:	18147
    I haven't tried it yet but this looks like exactly what I need. Thank you very much sir.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-23-2014, 04:34 PM
  2. Replies: 7
    Last Post: 02-10-2012, 08:08 PM
  3. Make new field based on previous field's answer
    By VictoriaAlbert in forum Access
    Replies: 1
    Last Post: 04-11-2011, 09:54 PM
  4. Populate field from field on previous record
    By randolphoralph in forum Forms
    Replies: 7
    Last Post: 03-04-2011, 11:28 AM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 PM

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