Results 1 to 7 of 7

Thread: [RESOLVED] Getting Sum on right side

  1. #1
    Hyperactive Member
    Join Date
    Nov 10
    Location
    Pakistan
    Posts
    270

    Resolved [RESOLVED] Getting Sum on right side

    Can i sum two left columns in datareport of vb6, I have two bounded textboxes which obtained data from database and i want to display sum of every record on their right side. Can i do this? If yes then what is the procedure?

  2. #2
    Frenzied Member
    Join Date
    Sep 05
    Location
    Modesto, Ca.
    Posts
    1,592

    Re: Getting Sum on right side

    You can probably do it with your sql statement, but need a lot more info on how you designed the report.

  3. #3
    Hyperactive Member
    Join Date
    Nov 10
    Location
    Pakistan
    Posts
    270

    Re: Getting Sum on right side

    So, you can guide me through the whole process

  4. #4
    Hyperactive Member
    Join Date
    Nov 10
    Location
    Pakistan
    Posts
    270

    Re: Getting Sum on right side

    Can anybody give me reply? I need it urgently.

  5. #5
    Frenzied Member
    Join Date
    Sep 05
    Location
    Modesto, Ca.
    Posts
    1,592

    Re: Getting Sum on right side

    You SQL statement would look something like this, "Select field1, field2, (field1 + field2 ) as sumtotal from yourtablename". This is just a guess, you haven't explained what your using for the reports datasource.

  6. #6
    Hyperactive Member
    Join Date
    Nov 10
    Location
    Pakistan
    Posts
    270

    Re: Getting Sum on right side

    I used following code for displaying data in two textboxes and want to insert a label on right side which will used for getting sum of two left columns:

    Private Sub cmdPrint_Click()
    Dim str As String
    If modText.myConn.State = adStateOpen Then
    modText.myConn.Close
    End If

    Set myRs = Nothing

    If cmbMonth.Text = "" Or txtYear.Text = "" Then
    MsgBox "Please enter both values for Monthly Income Report", vbOKOnly, "Ideal"
    cmbMonth.SetFocus
    Else

    Call modText.OpenMyConn

    myRs.Open "SELECT query3.fcd AS `CURRENTDATE`, sum(query3.fdf) AS `DEPOSITEDFEE`, sum(query3.ta) AS `INCOME` from query3 where month(query3.fcd)= " & cmbMonth.Text & " and year (query3.fcd)= " & txtYear.Text & " group by query3.fcd UNION select query4.tcd, sum(query4.fdf), sum(query4.ta) from query4 where month(query4.tcd)=" & cmbMonth.Text & " and year (query4.tcd)= " & txtYear.Text & " group by query4.tcd", myConn, adOpenKeyset, adLockOptimistic


    Set rptMonIncome.DataSource = myRs
    rptMonIncome.DataMember = myRs.DataMember

    rptMonIncome.Show
    Unload Me

    End If
    End Sub

  7. #7
    Hyperactive Member
    Join Date
    Nov 10
    Location
    Pakistan
    Posts
    270

    Re: Getting Sum on right side

    I have solved this problem

Posting Permissions

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