how to calculate this function ? (1 Viewer)

Dlovan-IT

Registered User.
Local time
Today, 09:47
Joined
Oct 9, 2013
Messages
84
hell all programers

i have a table this table i used for debt the column like that

Name Price
==== ====
Jack 50$
Jack 60$
David 70$

Sum of Jack = 110$

now jack paid lets say 50$ and remain 60$ how to calculate this ?

thanks for help
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:47
Joined
Aug 30, 2003
Messages
36,127
One way would be to create a third entry for Jack with a negative 50. That way you can still sum the table.
 

Dlovan-IT

Registered User.
Local time
Today, 09:47
Joined
Oct 9, 2013
Messages
84
thanks for your reply but i want by vba if any body can do it
 

vbaInet

AWF VIP
Local time
Today, 07:47
Joined
Jan 22, 2010
Messages
26,374
Is it really about what you want or what the best solution is?

You should already have all the payments stored in a table so all you do is prefix it with a minus sign and run a SUM totals query.

Unless you mean that you want calculations calculated on the fly when the user enters 50 as payment. Perhaps you should properly explain what you're trying to do and where you're trying to do it.
 

tehNellie

Registered User.
Local time
Today, 07:47
Joined
Apr 3, 2007
Messages
751
You can achieve this in a number of different ways. You could perhaps extend your existing table to include a "category" (id) column so that your "price" column accommodates positive and negative values. I.e if you have a category of "deposit" and another category of "withdrawal" you can fairly easily maintain a balance.

This isn't a VBA question, it relates, pardon the pun, to your underlying table and query design.
 

Users who are viewing this thread

Top Bottom