Soring / Group on a listbox

S

srm

I have a list box using checkboxes. Using Outlook 2003. I have two
questions.

When grouped, if I have multiple items selected, it separates them out
into its own band (grouping). Is there a way to have a grouping with
multiple items selected?

Is it possible to sort on a list field?

Maybe a list box is not what I need based on the above items. Is
there another control that I can use that would allow the above
(ability to select multiple items, group and sort). I tried a combo
box which allows this capability, but I'm always adding new
combination of entries.

Any help / ideas would be apprecaited.

thxs

srm
 
P

Paul Mac

Hi srm,

Not sure if fully understand what you are referring to by grouping, but if
it is the use of the "Group" view then this may help you.

It sounds like you have the control bound to a UDF - Keywords field. For
each item in the list box, when selected it becomes a distinct group in that
view. There are two possible solutions.

1. You could add routine in the Item_Write, Item_Open to update an another
text box, that will add the selected items as a complete string. Therfore
when you use the group function, it will group literally by the entire
string. Note: There is a limitation of the length and that is 255 chr.
Otherwise it will truncate the item to 255 and you will end up with another
group.

Sue has an excellent example on her site demonstrating the use of unbound
listboxes.:
Page > http://www.outlookcode.com/d/formcontrols.htm
Demo > http://www.outlookcode.com/files/FormControlsDemo.zip

2. Sorting a listbox is quite simple. All you will need to do is adapt the
following code to suit your control names.

For x = 1 To objCollection.Count - 1
For z = x + 1 To objCollection.Count
If objCollection(x) > objCollection(z) Then
Swap1 = objCollection(x)
Swap2 = objCollection(z)
objCollection.Add Swap1, before:=z
objCollection.Add Swap2, before:=x
objCollection.Remove x + 1
objCollection.Remove z + 1
End If
Next z
Next x
HTH, Paul Mac.
 

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