Skip to Content
author's profile photo Former Member
Former Member

sub total of a grid row?

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
        Dim oForm As SAPbouiCOM.Form
        Dim sumdepth As Decimal = 0.0
        oForm = SBO_Application.Forms.Item(FormUID)
        If (pVal.ItemUID = "btexcute") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
            Dim sql1 As String
            oForm.DataSources.DataTables.Add("MyDataTable")
            sql1 = "select CardCode, CardName, DocDate, DocNum, DocTotal, DocStatus from OINV where DocDate  between '" & oForm.Items.Item("Stdt").Specific.value & "' and  '" & oForm.Items.Item("enddt").Specific.value & "'"

            oForm.DataSources.DataTables.Item(0).ExecuteQuery(sql1)
            oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable")
            'Set columns size
            oGrid.Columns.Item(0).Width = 50
            oGrid.Columns.Item(1).Width = 60
            oGrid.Columns.Item(2).Width = 130
        End If
        If (pVal.ItemUID = "btnCol") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
            Dim i As Integer
            oGrid = oForm.Items.Item("MyGrid")
            For i = 1 To oGrid.Rows.Count-1
                sumdepth += oGrid.Columns.Item("DocTotal").Cells.Item(i).Specific.Value
                oForm.Items.Item("Tqval").Specific().value = sumdepth
            Next
        End If
    End Sub

grid total value row is not calculated?

i want to know sub total of a row of a grid value....?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 02:53 PM

    If the control you are using is a Grid you must start your loop with 0. The Rows indexes are zero based. Also try converting the value to a numeric format

    Dim i As Integer
    oGrid = oForm.Items.Item("MyGrid")
    For i = 0 To oGrid.Rows.Count-1
       sumdepth += CDec(oGrid.Columns.Item("DocTotal").Cells.Item(i).Specific.Value)
       oForm.Items.Item("Tqval").Specific().value = sumdepth
    Next

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.