Print Page | Close Window

[SOLVED] GroupRow SumSub With SubTotals

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=17313
Printed Date: 05 October 2024 at 12:54am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED] GroupRow SumSub With SubTotals
Posted By: Xander75
Subject: [SOLVED] GroupRow SumSub With SubTotals
Date 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)



Replies:
Posted By: Aaron
Date 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....


Posted By: Xander75
Date 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)


Posted By: Aaron
Date 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....


Posted By: Xander75
Date 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)


Posted By: SHAN
Date 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


Posted By: RJAMIN
Date 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)?



Posted By: Xander75
Date 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)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net