F
fiona.bremner
I'm working on a financial report and need to get a Year to Date sum
of the values for the fiscal period's that have elapsed. The table
structure looks like this:
ACT_PER_01, ACT_PER_02, ACT_PER_03, .....ACT_PER_12
The Fiscal Period fields are the ones called ACT_PER_XX. So, the user
enters the fiscal period they want the report for and I need to sum up
ACT_PER_01 to the period they entered to get the Year to Date value.
My code runs, and I get a YTD Sum, but the value is off. I used the
loop below to create the SQL:
'loop thru fiscal periods for the year up to and including the
fiscal period entered
For i = 1 To FiscalPeriodCounter Step 1
ActualYTDSql = ActualYTDSql & " + " & "ACT_PER_" & IIf(i <
10, "0" & i, i)
Next i
The loop above gives me (after a little clean up):
" ( ACT_PER_01 + ACT_PER_02 + ACT_PER_03) as ActualYTDSql "
I run my sql and get my results. Then I sum (ActualYTDSql ) and it
doesn't quite equal the result I get if I SUM(ACT_PER_01) and
SUM(ACT_PER_02) and SUM(ACT_PER_03 ) and add those three results
together.
I can't seem to figure out why they aren't equal. Does anyone know
what might be wrong?
of the values for the fiscal period's that have elapsed. The table
structure looks like this:
ACT_PER_01, ACT_PER_02, ACT_PER_03, .....ACT_PER_12
The Fiscal Period fields are the ones called ACT_PER_XX. So, the user
enters the fiscal period they want the report for and I need to sum up
ACT_PER_01 to the period they entered to get the Year to Date value.
My code runs, and I get a YTD Sum, but the value is off. I used the
loop below to create the SQL:
'loop thru fiscal periods for the year up to and including the
fiscal period entered
For i = 1 To FiscalPeriodCounter Step 1
ActualYTDSql = ActualYTDSql & " + " & "ACT_PER_" & IIf(i <
10, "0" & i, i)
Next i
The loop above gives me (after a little clean up):
" ( ACT_PER_01 + ACT_PER_02 + ACT_PER_03) as ActualYTDSql "
I run my sql and get my results. Then I sum (ActualYTDSql ) and it
doesn't quite equal the result I get if I SUM(ACT_PER_01) and
SUM(ACT_PER_02) and SUM(ACT_PER_03 ) and add those three results
together.
I can't seem to figure out why they aren't equal. Does anyone know
what might be wrong?