[AccessD] Unable to deselect items in unbound combobox

Charlotte Foust charlotte.foust at gmail.com
Wed Dec 31 13:12:53 CST 2014


I usually set comboboxes to null, but I don't usually allow multiple
selection comboboxes.  I rarely use listboxes.

Charlotte

On Wed, Dec 31, 2014 at 9:10 AM, Bill Benson <bensonforums at gmail.com> wrote:

> I have a listbox that when it is requeried, I desire to deselect any of its
> contents, and then, since it's column 0 value represents the intended
> product id, on which the form itself is positioned, I want there to be no
> current record of the form (until such time as the user makes a selection
> in
> the listbox), as well as a bunch of other unbound controls to be set to
> null
> or the equivalent. Many of those controls are unbound comboboxes, and here
> comes my problem. I pass the controls to this function and while I am not
> getting any errors and the selected property of each item in the combo is
> apparently both false at the time the routine happens to be called (in this
> instance),
>
>
>
> 1)      The listindex appears nevertheless to be other than -1, and
>
> 2)      The listindex does not change.
>
>
>
> The result of this is that I am not seemingly able to de-select any value
> already showing in those combos.
>
>
>
> Private Sub ClearField(ctrl As Control)
>
> Dim i As Long
>
> Select Case TypeName(ctrl)
>
>
>
> Case Is = "Listbox"
>
>     For i = 0 To ctrl.ListCount - 1
>
>         ctrl.Selected(i) = False
>
>     Next
>
> Case Is = "ComboBox"
>
>     For i = 0 To ctrl.ListCount - 1
>
>         ctrl.Selected(i) = False
>
>     Next
>
> Case Is = "TextBox"
>
>         Ctrl=""
>
> Case Is = "CheckBox"
>
>     ctrl = False
>
> Case Else
>
>     MsgBox "Fix code!"
>
> End Select
>
>
>
> End Sub
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list