Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [SOLVED] GroupRow SumSub With SubTotals
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] GroupRow SumSub With SubTotals

 Post Reply Post Reply
Author
Message
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] GroupRow SumSub With SubTotals
    Posted: 24 September 2010 at 7:44am
Hi,

I have used the following code to correctly add a Total to the GroupRow column of my choice, I am also aware of the limitation of the calculation if the column numeric values contains a comma.


    Dim GroupRow As ReportGroupRow, Row As ReportRow

    For i = 0 To rpcGrid.Rows.Count - 1
        Set Row = rpcGrid.Rows(i)
        If Row.GroupRow Then
            Set GroupRow = Row
            GroupRow.GroupFormat = "%.0f"
            GroupRow.GroupFormula = "SUMSUB(C9:C10)"
            GroupRow.GroupCaption = "x"
        End If
    Next
    rpcGrid.ReCalc True
    rpcGrid.ReDraw


What I would like to know is if there is anyway in which to divide the GroupFormula by 2, or even loop through and only select the Rows required to add to the SUMSUB calculation? The reason I ask is that my child rows contain Sub Totals, therefore the SUMSUB calculation is doubling up the Total in the GroupRow.



I have tried to fix this but I have not yet found a solution to this issue.
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2010 at 5:58am
Hi,
 
How do you create the subtotals? Is it just reportitem?
Can you upload small demo?
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2010 at 5:04am
Hi,

You're correct, the Subtotals are just an extra ReportItem that I use prior to adding any new data that does not match that of the previous record. Then I use the BeforeDrawRow to do the colouring, font bold & underline.
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2010 at 12:36pm
Hi,
 
Use same event (BeforeDrawRow event) and use Metrics object to show value. Metrics.Text supports Markup as well.
 
  
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 28 September 2010 at 4:53am
Thanks Aaron!!!

Using your suggestion I have managed to resolve the issue I had with the Group Row SUMSUB calculation.



I had to overcome the FormatNumber issue too, so I will post the following code for anyone else who has had this issue in the past, present or future!


' Required to fix the FormatNumber issue after the Group Row SUMSUB has been calculated
Dim bFormatNumber As Boolean

' First set the variable bFormatNumber = False before adding the records to the ReportControl, do NOT format the text using FormatNumber at this time!!!
' Once you have added records to the ReportControl, called ReportControl.Populate and added the code to display the Group Row SUMSUB calculation
' Then set bFormatNumber = True & also ReportControl.SetFocus


Private Sub rpcGrid_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)

    ' Format Group Row Calculations
    If Row.GroupRow Then
        Dim sTextToFind As String
        iPos = InStr(Metrics.Text, "[9]")
        If iPos > 0 Then
            sTextToFind = Mid$(Metrics.Text, iPos + 3, Len(Metrics.Text))
            Metrics.Text = Replace$(Metrics.Text, sTextToFind, FormatNumber$(CDbl(sTextToFind) / 2, 0))
        End If
    End If
   
    ' Format the rows to display the "," delimiter in the column with a numeric value
    If bFormatNumber Then
        Row.Record(9).Value = FormatNumber$(Row.Record(9).Value, 0)
    End If

End Sub



Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
SHAN View Drop Down
Groupie
Groupie
Avatar

Joined: 17 July 2010
Location: Dubai
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote SHAN Quote  Post ReplyReply Direct Link To This Post Posted: 29 September 2010 at 11:57am
Hi,
 
Please add this  types of Code  in Code snipplet topic 
 
This will help lot of Users to quickly view by topic....
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows 7 Professional
Language: Visual Basic 6.0
Back to Top
RJAMIN View Drop Down
Newbie
Newbie
Avatar

Joined: 29 September 2010
Location: Houston, TX
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote RJAMIN Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 4:03pm

Do you allow additional grouping or real-time grouping (User can drag and drop column to group by)?

Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 18 October 2010 at 3:22am
@ RJAMIN
 
The short answer is "no"! The requirement I had was for a static report were the report was grouped exactly as required with no need for further manipulation.
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
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.187 seconds.