|
| [WD19] Table break calculation problem |
| Iniciado por guest, 20,dic. 2015 20:11 - 3 respuestas |
| |
| | | |
|
| |
| Publicado el 20,diciembre 2015 - 20:11 |
Hi,
I have a table (filled by programming with tableaddline) with two breaks on it and let calculate totals and subtotals.
So far this works, but the calculation seemes to be done not before the corresponding part of the table is displayed.
So if I Loop through the table to do some more calculation using the automatic results of the totals, most times the result is false. If i do the calculation while the corresponding part of the table is visible, then the result is ok.
Actually if you scroll through the table with the srollbar, so that each entry is seen at least once, and then do the additional calculations, all is ok.
Putting the code in the Display of break Event does not help, sometimes wrong, sometimes good.
Any ideas out there?
Erik |
| |
| |
| | | |
|
| | |
| |
| Publicado el 20,diciembre 2015 - 23:53 |
I had a similar problem where I also had to run a secondary query for calculations. So I wrote an update procedure called after the TableDisplay the looped through the table and used the TableBreakSubscript command to locate where the break controls to update were located.
HTH, Jeff
Sample of code: Message("Updating R & I totals...") gwsPrevPartID = "" nRows is int = TableCount(TBL_CostHistory) FOR i = 1 TO nRows IF modulo(i,20) = 0 THEN Message(StringBuild("Updating R & I totals: %1 of %2",i,nRows)) END iBreakNdx is int = TableBreakSubscript(RUPT_BreakFooter_Part_ID,i) IF gwsPrevPartID <> COL_PART_ID THEN // Reset total fields as soon as Part_ID changes // gwiCurrentRow = 0 TBL_CostHistory[iBreakNdx].EDT_R_Qty = 0 TBL_CostHistory[iBreakNdx].EDT_R_TotalCost = 0 TBL_CostHistory[iBreakNdx].EDT_I_Qty = 0 TBL_CostHistory[iBreakNdx].EDT_I_TotalCost = 0 TBL_CostHistory[iBreakNdx].EDT_I_TotalPrice = 0 gwsPrevPartID = COL_PART_ID END IF COL_CLASS ~= "R" THEN TBL_CostHistory[iBreakNdx].EDT_R_Qty += COL_QTY TBL_CostHistory[iBreakNdx].EDT_R_TotalCost += COL_TotalActCost IF TBL_CostHistory[iBreakNdx].EDT_R_Qty <> 0 THEN TBL_CostHistory[iBreakNdx].EDT_R_AvgCost = (TBL_CostHistory[iBreakNdx].EDT_R_TotalCost/TBL_CostHistory[iBreakNdx].EDT_R_Qty) END END IF COL_CLASS ~= "I" THEN TBL_CostHistory[iBreakNdx].EDT_I_Qty += COL_QTY TBL_CostHistory[iBreakNdx].EDT_I_TotalPrice += COL_PriceXQty ..... |
| |
| |
| | | |
|
| | |
| |
| Publicado el 21,diciembre 2015 - 11:24 |
Hi Ericus,
An "offline" calculation can look like this: nRow=1 WHILE nRow <= Table..Occurrence // Subscript of the current break nBreakHeader=TableBreakSubscript(Table.BRK_BreakHeader1,nRow) nBreakFooter=TableBreakSubscript(Table.BRK_BreakFooter1,nRow) //Do your thing here // Go to the next break nRow=nBreakFooter+1 END Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 21,diciembre 2015 - 15:24 |
Hi all,
not what could be wished, but works so far:
At least the calculation must be done in each 'Display break' process (I have two nested breaks) and(!) the calculation must be done for each available break in the table then.
Your hints finally gave me the solution (better saying workaround) fot the Problem.
Thanks and have a nice Christmas
Erik |
| |
| |
| | | |
|
| | | | |
| | |
|