Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15504

problem with sum in diferent many tables

$
0
0
I'am using vb2008 - ms access
i tried this code to sum values from three tables
and i put them in Form load
SumComR3()
SumMnyD()
SumMnyPT()
the problem is when any of these three tables has no any record, another code of another table don't sum any value
it means when table6 has no record. the s SumMnyD and SumMnyPT don't sum the values in table5 and table4
Code:

Public Sub SumComR3()
        conn.Open()
        Dim cmd5 As New OleDbCommand("select sum(ComR3) from Table6", conn)
        Form7.txtComR3.Text = cmd5.ExecuteScalar
        conn.Close()
    End Sub

    Public Sub SumMnyD()
        conn.Open()
        Dim cmd6 As New OleDbCommand("select sum(MnyD) from Table5", conn)
        Form7.txtMnyD.Text = cmd6.ExecuteScalar
        conn.Close()
    End Sub

    Public Sub SumMnyPT()
        conn.Open()
        Dim cmd7 As New OleDbCommand("select sum(MnyP) from Table4 where KindP = 'somthing' ", conn)
        Form7.txtMnyPT.Text = cmd7.ExecuteScalar
        conn.Close()
    End Sub


Viewing all articles
Browse latest Browse all 15504

Trending Articles