Hi,
Is there any possibility to sum all the values in many (say n) columns in a single table using VBA in access 2003?
Say I have a table with 200 columns. Say the table name is TableCOUNT and the columns inside the table have names such as LX1, LX2,....,LX200.
If I use DSum for a single (or a few) columns giving the name of the column, everything is OK. I get a total for this (these) ciolumns:
But if I want to go through 200 columns with a loop, the DSum instead of returning the sum in each column, returns the sum of the NUMBER OF CELLS IN EACH COLUMN!!! (eg. If I have 200 columns with 10 cells I get a sum of 2000, with intermediate values in the LOOP being 10, 20, 30,...,2000:
Any ideas to solve this problem?
Thanks in advance
Is there any possibility to sum all the values in many (say n) columns in a single table using VBA in access 2003?
Say I have a table with 200 columns. Say the table name is TableCOUNT and the columns inside the table have names such as LX1, LX2,....,LX200.
If I use DSum for a single (or a few) columns giving the name of the column, everything is OK. I get a total for this (these) ciolumns:
Code:
Open "N:\FM AM\TEST_LOG1.txt" For Output As #intOutFile
Print #intOutFile, "Printing sum of a single column LX5 in TableCOUNT table"
curX1 = DSum("[LX5]", "TableCOUNT")
Print.Debug curX1
Print #intOutFile, curX1
Close intOutFile
Code:
Open "N:\FM AM\TEST_LOG1.txt" For Output As #intOutFile
Print #intOutFile, "Printing sum of each column in TableCOUNT table"
For yy = 1 To 200
curX1 = DSum(yy, "TableCOUNT")
If curX1dif < 1 Then Print #intOutFile, "WARNING!!! All values in this Fund are ZERO"
Print.Debug curX1
Print #intOutFile, curX1
Next yy
Close intOutFile
Thanks in advance
Comment