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?
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.
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
Set myRs = Nothing
If cmbMonth.Text = "" Or txtYear.Text = "" Then
MsgBox "Please enter both values for Monthly Income Report", vbOKOnly, "Ideal"
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