Hi ALL,
newb on the forum and somewhat newb with Codejock components. Using VB6 SP6 and Xtreme Suite Trial 12.0.1
My question is about the ValueChanged event of ReportControl. I´m writing an application where the user is supposed to edit directly the contents of the ReportRecordItems, which appears as cells in the ReportControl. After editing the contents of the cell or inputing an value in a blank cell, I understand that first of all the ValueChanging event is fired and after that the ValueChanged event is fired.
I also understand that when the ValueChanged event is fired, the contents of the ReportRecorItem associated with the active cell is also updated. So I would like to format the Caption property of this cell AFTER it is updated or input. The value itself will be used to perform running totals calculations and for that I wrote the following code:
Private Sub rcCM_ValueChanged(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem) Dim Record As ReportRecord, NewCol As ReportColumn Dim Quant As Currency, Price As Currency, Total As Currency Dim i As Long
'Perform calculations of subtotals Set Record = Row.Record If Record.Item(3).Caption <> "" Then Quant = CCur(Record.Item(2).Caption) Price = CCur(Record.Item(3).Caption) Total = Quant * Price 'Record.Item(3).Caption = Format$(Price, "STANDARD") <- Problem!!! Record.Item(4).Caption = Format$(Total, "STANDARD") End If
'Perform running total calc TotalMaterial = 0 For i = 0 To 6 Set Record = rcCM.Records(i) TotalMaterial = TotalMaterial + CCur(Record.Item(4).Caption) Next lblCustoMaterial.Caption = Format$(TotalMaterial, "STANDARD")
'Change focus to next row If Row.Index <= rcCM.Rows.Count - 2 Then If Column.Index = 2 Then Set NewCol = rcCM.Columns(3) rcCM.EditItem Row, NewCol ElseIf Column.Index = 3 Then Set NewCol = rcCM.Columns(2) Set Row = rcCM.Rows(Row.Index + 1) rcCM.EditItem Row, NewCol End If End If End Sub
As you can see, the subtotals are calculated right at the beginning of the Sub and it works 100%, even when editing values. If, on the ohter hand, I uncomment the instruction marked as problematic, to format the number in the cell, it doesn´t work anymore. If the cell is blank and a value is input, it works ok, but if there´s already a value and it is edited, after you press Enter the value is returned to the first value that was input in the cell.
It doesn´t matter if I reference the cell as in my example or if it is referenced by the Item argument of the event procedure. If I try to format the number and put it back, it doesn´t work as expected.
Any ideas?
Thanks in advance for any advice you may give!
|