[AccessD] Unable to deselect items in unbound combobox

Bill Benson bensonforums at gmail.com
Wed Dec 31 13:17:45 CST 2014


Ah, that seems to be the key to unlocking a mystery (to me) Charlotte:  the
Selected property must be only effective if a control as capability to allow
multiple selections. Thank you.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Wednesday, December 31, 2014 2:13 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Unable to deselect items in unbound combobox

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
>
--
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