Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Multi-select listbox issues

Multi-select listbox issues

Multi-select listbox issues


I have an issue which I'm hoping to get some help with. There is a DynaSet form which is tied to a table called: tblBasicInfo.

Everything works as expected except for a listbox. I have placed a checkbox next to it, to allow users to select all the entries:

Private Sub chkAllSpecialties_Click()

Dim i As Integer

Dim selection As Boolean
selection = chkAllSpecialties.Value

For i = 0 To lstSpecialties.ListCount - 1
lstSpecialties.Selected(i) = selection
Next i

End Sub

This works as expected. But I can't seem to get the selected values stored in the Control Source field (which is a Long Text field).

The values don't get stored even if I manually select values. The values for all other fields (including the checkbox) get stored and populate upon form load as expected.

Any insight with this issue is greatly appreciated.

RE: Multi-select listbox issues

Not sure what you are expecting to happen. A standard multiselect listbox cannot be bound to a field; a single field cannot store multiple values. Are you expecting the values to be concatenated somehow? If you want to store multiple values in a single field you would need to use a multivalue field and a multivalue field control, not a standard listbox. If you want to concatenate the values somehow you would have to write code, and I would not recommend it.

RE: Multi-select listbox issues

Thanks for the reply. I updated the field to be multi-select and the control to be a listbox. So multiple selections can now be stored. The desired behavior is that the user should be able to check/un-check the 'Select All' checkbox and all/none of the listbox values should get either selected or unselected and the result should get stored. The selection/un-selection is easily accomplished via:


Private Sub chkAllSpecialties_Click()
    Dim i As Integer
    Dim selection As Boolean
    selection = chkAllSpecialties.Value
        For i = 0 To SpecialtiesSelected.ListCount - 1
            SpecialtiesSelected.Selected(i) = selection
        Next i
End Sub 

The problem is that the selection/un-selection does not result in an update to the underlying multi-value field.

RE: Multi-select listbox issues

A multi select field has its own set of controls and you cannot use a standard listbox as previously stated.

RE: Multi-select listbox issues

Personally I don't like to 'juggle' information between variables.


Private Sub chkAllSpecialties_Click()
    Dim i As Integer
    With lstSpecialtiesSelected
        For i = 0 To .ListCount - 1
            .Selected(i) = chkAllSpecialties.Value
        Next I
    End With
End Sub 

But that may be just me... smile

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Multi-select listbox issues

Hi MajP,

Good point - and a correction on my part. I meant that I changed the field type to be a multivalue and not a multi-select. I believe multivalue fields can be represented visually as ListBoxes or ComboBoxes. I decided to represent it as a ListBox. Now if I manually check multiple values, the selections are stored in the multivalue field correctly.

I am also able to use the check all checkbox to select all the values appearing in the listbox. Unfortunately when moving to the next record, these automatically selected values do not get stored into the multivalue field.

So I believe the type of field, the type of control and the association are correct. But something is missing that would allow the associated field to be updates with the values of the automatically selected values in the list box.


RE: Multi-select listbox issues

I cannot see the problem, but I tested it and it worked. I created a multivalue field, and selected/deselected all values and the selected values were stored. There may be something else going on.

RE: Multi-select listbox issues

Thanks for the update. Just out of curiosity, did you select/de-select all using an event (something similar to what was posted on check/uncheck) or did you select/de-select manually. When I do it manually, the field is indeed updated. When I click the independent check-box to select/de-select all, the listbox entries all get get selected/de-lected as expected, but the field never gets updated.

RE: Multi-select listbox issues

I did it in code like you did, and it seemed to work.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close