Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum of Recordset????

Status
Not open for further replies.

Sarah28

IS-IT--Management
Aug 6, 2000
16
US
I would like to use a select statement to select a group of records and then display the sum of those records... I am currently using the following code, but only get the value of the first record, not the sum, does anyone know how to get the sum of records in a recordset? (varactual should refelct the sum) THANKS IN ADVANCE


varprojectid = Me.PONumber & "00"

stractual = "SELECT DrAmt FROM dbo_GLTran Where ProjectID = " & varprojectid & "AND TaskId Like '%Ocean Freight%'"

Set DbI = CurrentDb
Set qdfI = Db.CreateQueryDef("", stractual)
Set rstI = qdf2.OpenRecordset(dbOpenSnapshot)

If rst1.RecordCount > 0 Then

varactual = RTrim(rst1.Fields("Percentage").Value)

Else
End If

 
Use DSum("FieldName", "Recordset", "Criteria").


DSum("Percentage", rstI)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top