Multiselect listbox - reading amount of values selected and values

E

Eve

You will probably need several queries to get to desired
result. The text field that users input amounts must be a
field that you have added to the tblEmployees. Then the
amount will be tied to the correct employee. Then you can
easily create a query based on that table for your
calculation. In order to get the amount of names that
were entered, create a query that is grouped, and use
the "Count" grouping option on the names.
Hope this helps,
Eve
 
D

Dirk Goldgar

Przemek Wrzesiñski said:
Piêknego dnia Tue, 9 Sep 2003 06:41:59 -0700, osobnik ukrywajacy sie
pod pseudonimem "Eve" <[email protected]> w wiadomosci


I figured out different thing.
Dim ctlSource As Control
Dim intCurrentRow As Integer
Dim Choice As String

Set ctlSource = EmployeeList

For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
Choice = Choice + ctlSource.Column(0, intCurrentRow)
End If
Next intCurrentRow
Set ctlSource = Nothing

At the end of this I'm receiving string with id's selected employees.
Length of string tells me the number I have to divide given amount by
and the content of string tells me the employee/employees selected.
Each id's combination is unique, so using if/else/end if construction
I can fill another (not tblEmployee) table with records.

Przemek

Rather than looping through all the items in the list and only acting on
the selected ones, you could simplify your logic by using the list box's
ItemsSelected collection. EmployeeList.ItemsSelected.Count tells you
how many employees were selected, and each item in the collection is the
row number of a selected employee.
 

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