Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Format$ question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Format$ question

 Post Reply Post Reply
Author
Message
GrinderBR View Drop Down
Newbie
Newbie
Avatar

Joined: 09 September 2009
Location: Brazil
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote GrinderBR Quote  Post ReplyReply Direct Link To This Post Topic: Format$ question
    Posted: 09 September 2009 at 8:47pm
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!
 
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 10 September 2009 at 12:54pm
Formula support - feature of version 13.2 - no sense to try it with previous versions
You can set your report to make calc for you without your fired functions
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.