Don,
First, if your listbox rowsource is from a table or query, then it will
probably be quicker to use the DSUM function to sum the column using the
same query or table as you used in the listbox. Something like:
me.txtTotal = DSUM("yourColumn", "yourQueryOrTable", strCriteria)
where strCriteria is optional and represents any filtering of the
Table/Query that you want to do before doing your summation.
If, on the other hand, your listbox is filled from a value list (you entered
the number manually, or created the list using some code and the AddItem
method), then you will need to loop through the items in the list, keeping
in mind that the columns in the listbox are basically a zero based array.
You don't indicate whether you want to sum all of the rows, or just those
that are selected, so I'll assume you want to to all values. You also don't
indicate what action would kick off this routine, so I'll put it in a
function of its own, so you can call the function and fill the textbox any
time you want. You would call this function something like the following,
from somewhere within your form
me.txtTotal = ListSum(me.LstSchedule)
Public Function ListSum(lst As Object, ColRef As Integer) As Double
Dim intLoop As Integer
ListSum = 0
'Loop through each row of the listbox. If the columnheads property is
true,
'you have to increment the loop counter by 1 to skip the headers
For intLoop = 0 - lst.ColumnHeads To lst.ListCount - 1 - lst.ColumnHeads
Debug.Print intLoop, ColRef, lst.Column(ColRef, intLoop)
ListSum = ListSum + lst.Column(ColRef, intLoop)
Next intLoop
End Function
HTH
Dale