Database sums

sterjo

Member
Joined
Aug 13, 2006
Messages
5
Programming Experience
Beginner
I have an access database which has 4 columns sum, sum1,sum2,sum3. The database fills only columns sum and sum1, sum2 and sum3 are epmpty they can be also virtualy created, i don't mind that, because I only need to get the calcualtion displayed in a datagrid. So the code should compare each record in sum and sum1 and if sum is larger than sum1 it should subtract it and pass it to the dummy column. Now if sum1 is larger than sum, the difference goes to another dummy column. However, the code should also check the numbers in virtualy created columns and if previous record is larger than the next one it should substract it again. It should be some sort of circular reference, now I have achievd this in an old programming database language but here I have no idea. so as I mentioned before

SUM sum1 sum2 sum3
1 0 1 0
1 0 2 0 (record of sum is added to the previous record of sum2)
0 1 1 0 (now a record is added to sum1, but since sum2 > sum1, it substratcs it )
0 2 1 1 ( now sum1 >sum2 and the difference goes to sum3)
0 3 0 2 ( once again since sum1 is larger than sum it substratcts sum2 and it passes the value to to sum3)
God I hope I dind't confuse you, when this was introduced to me, I was like trhis :eek: I hope someone can help me with this casue I have no idea how to solve this. In addition, I should add the fact that I'm still learning the visual studio.
 
Talk about running before you can walk...

You need to fill a data table with your data, then go over it row by row, looking back at the previous row for some of your calcs. For info on how to fill a datatable with data, see the DW1 link in my sig.

ps; if youre still learning visual studio, i really recommend you get VB2005, not 2003 - 2003 is 4 years old now and a lot has changed in 2005 that makes it better and easier.
 
Back
Top