sum values from selected items in multi-select listbox

M

Marianne

I have a form with a field where the user enters an invoice No. I also have a
multi-select listbox on the form that is populated with all the lines from
that invoice. I would like the user to be able to select individual lines and
have the sum of those lines entered into a separate box on the same form. Is
this possible? and how?
 
P

Paul Shapiro

Something like this, from the online help:
Sub RowsSelected()
Dim ctlList As Control, varItem As Variant

' Return Control object variable pointing to list box.
Set ctlList = Forms!Employees!EmployeeList
' Enumerate through selected items.
For Each varItem in ctlList.ItemsSelected
' Print value of bound column. NOTE: You would build your total here
Debug.Print ctlList.ItemData(varItem)
Next varItem
End Sub
 
M

Marianne

thank you works perfectly

Paul Shapiro said:
Something like this, from the online help:
Sub RowsSelected()
Dim ctlList As Control, varItem As Variant

' Return Control object variable pointing to list box.
Set ctlList = Forms!Employees!EmployeeList
' Enumerate through selected items.
For Each varItem in ctlList.ItemsSelected
' Print value of bound column. NOTE: You would build your total here
Debug.Print ctlList.ItemData(varItem)
Next varItem
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top