Results 1 to 7 of 7

Thread: display grandtotal from subtotal help

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    display grandtotal from subtotal help

    hello,please help.how to display the grangtotal from subtotal.

    this is the current code:
    Code:
         Set conDataConnection = New Connection
          conDataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & _
                    "\Overtime.mdb;Persist Security Info=False"
       
          Set rs = New ADODB.Recordset
        strSQL = "select Department,WorkDescript, SUM(OtHours) As OtHours from Overtime where OvertimeDate BETWEEN #" & start & "# and #" & enddate & "# Group by Department ,WorkDescript "
              
       
    rs.Open strSQL, conDataConnection, adOpenStatic, adLockOptimistic
    
    While Not rs.EOF
            If IsNull(rs("OtHours").Value) Then
                total = total + 0
            Else
                total = total + rs("OtHours").Value
            End If
            rs.MoveNext
        Wend
       
    'set the database source in rs
       rptalldept.Sections("Section5").Controls.Item("Label15").Caption = Format(total, "#,##0.00")
       rptalldept.Sections("Section4").Controls.Item("Label19").Caption = start
       rptalldept.Sections("Section4").Controls.Item("Label21").Caption = enddate
       Set rptalldept.DataSource = rs
        'then set the field
        rptalldept.Sections("section1").Controls.Item("Text1").DataField = "WorkDescript"
        rptalldept.Sections("section1").Controls.Item("Text13").DataField = "OtHours"
       rptalldept.Sections("section1").Controls.Item("Text4").DataField = "Department"
    rptalldept.Sections("section1").Controls.Item("Text4").DataField = GrandTotal
    thanks for help.
    Attached Images Attached Images  
    Last edited by gracehskuo; Jan 16th, 2008 at 03:31 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: display grandtotal from subtotal help

    Not clear where the problem is, a little more description would be helpful.

    I did notice this,
    rptalldept.Sections("section1").Controls.Item("Text4").DataField = "Department"
    rptalldept.Sections("section1").Controls.Item("Text4").DataField = GrandTotal
    You are assigning two values to the same control.

    Also you can use the "SUM()" control in the group footer and report footer for totals.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: display grandtotal from subtotal help

    wes4dbt:
    hi,thanks ya reply.i want to get the grandtotal from the subtotal.

    for exampls:
    department category work subtotal of category work
    Admin General work 10
    Admin others 15
    grandtotal:25 of department Admin from the subtotal of category work
    department category work subtotal of category work
    PC General work 40
    PC keyin 15
    grandtotal:55 of department Admin from the subtotal of category work

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: display grandtotal from subtotal help

    Why wouldn't the "SUM()" function do this for you?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: display grandtotal from subtotal help

    wes4dbt,
    hi,thanks you reply.how to SUM the grandtotal??please help.

    this is the current code:
    Code:
    strSQL = "select Department,WorkDescript, SUM(OtHours) As OtHours from Overtime where OvertimeDate BETWEEN #" & start & "# and #" & enddate & "# Group by Department ,WorkDescript "
    thanks for help.

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: display grandtotal from subtotal help

    Isn't this a VB6 DataReport?
    If so, there is "SUM" control. you would put it in the group footer section and set the Datafield property to Othours.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: display grandtotal from subtotal help

    yes i use vb6 datareport.ok i will try it.thanks ya

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width