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!
Last edited by gracehskuo; Oct 1st, 2007 at 10:38 PM.
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."