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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do Totals in a form properly?

Status
Not open for further replies.

VBUser77

MIS
Jan 19, 2005
95
US
I have a continuous form that has a detail section. I am showing values in the detail section. But I like to do totals ( a running sum). I can do it under the form footer section but it shows totals right at the end of the form. I like to show my totals right after the detail section values ends.

I can do it in report by using "Grouping and Filtering" but there is no "Grouping and Filtering" option when i work with my form.

Here is how it looks right now:


Name Value

Kim 10
John 20
Hick 40





Totals 70 (all the way at the end of the form)

I like my totals line to be right after Hick.

Any ideas/thoughts will be highly appreciated. Thanks a lot

Jay



 
You can always fake the running sum by doing a seperate query on the form's current event.

(Assumming you have a textbox that's called txtTotalValue.)

Private Sub Form_Current()

Dim strSQL as string
strSQL = "SELECT Sum(Value) AS MyTotal " _
& " FROM Sometable; "

Dim rst as DAO.recordset
Set rst = CurrentDB.Openrecordset(strSQL)

If not rst.eof or rst.bof
txtTotalValue = rst!MyTotal
end if

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top