Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012

    Unanswered: Cannot Get ListBox .ItemsSelected, help!


    i am unable to retrieve .ItemsSelected of a multiselect listbox on a form.

    1. the form is visible
    2. i manually select some items in the listbox.
    3. then in VBA i get the .ItemsSelected.Count property of the listbox.
    4. ItemsSelected.Count returns 0. This is a bug?
    5. i can clearly see items selected in the listbox.

    What's the problem?

    More info:
    i am loading several forms in Hidden mode.
    then i make only one form visible at a time by VBA.

    if i open this one form by itself, with no other forms loaded, then i am able to retrieve .ItemsSelected.Count value correctly.

    also posted to:
    Cannot Get ListBox .ItemsSelected, help!
    Access Help and How-to - Microsoft Office Cannot Get Listbox .itemsselected, Help! - UtterAccess Discussion Forums
    Cannot Get ListBox .ItemsSelected, help! - Access World Forums
    Cannot Get ListBox .ItemsSelected, help!

  2. #2
    Join Date
    Apr 2012

    thorough explanation here:

    "If the form isn't loaded when you make this reference to its class module, Access will load a hidden copy of the form and add it to the Forms collection."

    "remove all uses of Form_<form name> and replace them with the canonical usage:

    'DoCmd.OpenForm "FormName"' instead of 'Form_FormName.Visible = True'
    'Forms!FormName.ControlName' or 'Forms("FormName").ControlName' instead of Form_FormName.ControlName
    'DoCmd.SelectObject "FormName"' instead of Form_FormName.SetFocus

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts