UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Getting the Previous Record's Value    
 
   
MrMSAccess
post Mar 28 2008, 07:39 AM
Post #1

UtterAccess Addict
Posts: 136



I'm trying to get the previous record's value to do a type of running sum. I need to do something like the below.

ID.....Credit.....Debit.....Balance
1......5.00.......0..........5.00
2......10.00......0..........15.00
3......0.........5.00..........10.00.

Does anyone know a way I can do this in a query? I was thinking about identifying the previous id value but I can't figure out how to do it.
Go to the top of the page
 
+
jurotek
post Mar 28 2008, 08:21 AM
Post #2

UtterAccess VIP
Posts: 1,420
From: NV



Hi,
Take a look at ATT. I made you a sample of how it's done.
Attached File(s)
Attached File  CreditDebit.zip ( 19.72K ) Number of downloads: 5
 
Go to the top of the page
 
+
MrMSAccess
post Mar 28 2008, 08:23 AM
Post #3

UtterAccess Addict
Posts: 136



Thanks, juro. Is there anyway that you could just post the expression you used? I can't download through my server.
Go to the top of the page
 
+
jurotek
post Mar 28 2008, 08:27 AM
Post #4

UtterAccess VIP
Posts: 1,420
From: NV



oops I made a mistake, forgot to include Total to get Balance
Attached File(s)
Attached File  CreditDebit.zip ( 21.98K ) Number of downloads: 6
 
Go to the top of the page
 
+
jurotek
post Mar 28 2008, 08:30 AM
Post #5

UtterAccess VIP
Posts: 1,420
From: NV



Hi,
Create Field expression in query as such
Total: Nz([YourTable]![Credit],0)-Nz([YourTable]![Debit],0)

Create another Field expression
Cash Balance: Format(DSum("Total","QueryName","TablePK <=" & [TablePK]),"Currency")

If Credit or Debit not applicable you don't have to enter 0, Nz function will take care of it.

Edited by: jurotek on Fri Mar 28 9:37:44 EDT 2008.
Go to the top of the page
 
+
MrMSAccess
post Mar 28 2008, 10:17 AM
Post #6

UtterAccess Addict
Posts: 136



Thanks, Worked perfectly.
Go to the top of the page
 
+
jurotek
post Mar 28 2008, 10:18 AM
Post #7

UtterAccess VIP
Posts: 1,420
From: NV



YW,
Glad we could help.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 08:02 AM