calculating a sum using a column from list box

fratezone

Registered User.
Local time
Today, 03:13
Joined
Jan 20, 2002
Messages
23
Does anyone know how to reference a column from a list box AND able to add up all the numbers (column is $$$) to arrive at a total using a textbox (TOTAL).

I've been going my reference materials and noticed very little information on listboxes and it's properties.
Thanks
 
Something like this based on an original idea by Mr.Jack Cowley
Private Sub List13_AfterUpdate()
DoCmd.Requery
Dim ctl As Control, varItm As Variant, Answer As Currency, stDocName As String
Dim Criteria(30) As Currency
Set ctl = Me![List13]
For Each varItm In ctl.ItemsSelected
Criteria(varItm) = Round2C(ctl.Column(2, varItm))
Answer = Answer + Criteria(varItm)
Next varItm

Me.Text4 = Answer

End Sub
 
Thanks Rich.
I saw that code a couple of days ago when I was reviwing previous messages however this code runs when one selects a record. I need the code to run before selection. As a matter of fact, selecting has nothing to do with this. This code should only run once I execute a list and add up the $$ and it show the grand total in a text box.

Thanks for your help.
Ray
 
are you speaking of a "running sum" in the underlying query?
 
here's some code I came across. It is based on listbox properties for VB and I understand that their are some differences with Access but can you see any possibilities with this code?

Code:
Private Sub CommandButton2_Click()
Dim a As Single
For x = 0 To ListBox1.ListCount - 1
a = ListBox1.List(x)
b = a + x
Next
TextBox2.Text = b
End Sub
 

Users who are viewing this thread

Back
Top Bottom