Results 1 to 3 of 3

Thread: Total calculation

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Total calculation

    hello,please help with the total calculation.basically i use vb6 datareport to display the Total amount.i have problem with the Total display at the datareport.

    for example:
    8+5=13 but the report display result is 85.

    this is my code:
    Code:
    Dim strSQL As String
    Dim conDataConnection As Connection
    Dim departmment As String
    Dim enddate As String
    
    deptOTsummary.Orientation = rptOrientLandscape
    deptOTsummary.Show
    department = cbodepartment.Text
    
    
     Set conDataConnection = New Connection
          conDataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & _
                    "\Overtime.mdb;Persist Security Info=False"
    
    Dim rs As New ADODB.Recordset
    strSQL = "SELECT * FROM Overtime where Department='" & department & "'"
    rs.Open strSQL, conDataConnection, adOpenStatic, adLockOptimistic
    
    While Not rs.EOF
       ' total = total + rs("Othours").valu
            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
       deptOTsummary.Sections("Section5").Controls.Item("Label15").Caption = Format(total, "#,##0.00")
        Set deptOTsummary.DataSource = rs
        'then set the field
        deptOTsummary.Sections("section1").Controls.Item("Text1").DataField = "EmployeeName"
        deptOTsummary.Sections("section1").Controls.Item("Text2").DataField = "EmployeeNo"
        deptOTsummary.Sections("section1").Controls.Item("Text3").DataField = "Designation"
        deptOTsummary.Sections("section1").Controls.Item("Text4").DataField = "Department"
        deptOTsummary.Sections("section1").Controls.Item("Text5").DataField = "Shift"
        deptOTsummary.Sections("section1").Controls.Item("Text6").DataField = "OvertimeDate"
        deptOTsummary.Sections("section1").Controls.Item("Text7").DataField = "TimeFrom"
        deptOTsummary.Sections("section1").Controls.Item("Text8").DataField = "TimeTo"
        deptOTsummary.Sections("section1").Controls.Item("Text9").DataField = "Breaktime"
        deptOTsummary.Sections("section1").Controls.Item("Text10").DataField = "OtRate"
        deptOTsummary.Sections("section1").Controls.Item("Text11").DataField = "CategoryDay"
        deptOTsummary.Sections("section1").Controls.Item("Text12").DataField = "WorkDescript"
        deptOTsummary.Sections("section1").Controls.Item("Text13").DataField = "Othours"
    i post the error display image here.
    thanks for help!
    Attached Images Attached Images  
    Last edited by gracehskuo; Oct 1st, 2007 at 10:38 PM.

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