Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Multi Select ListBoxes (Access 97)

    Hi team

    Private Sub tboxHydrologicClass_GotFocus()
    Forms!frmSiteEdit!lboxHydrologicClass.Visible = True
    End Sub
    ----
    Private Sub lboxHydrologicClass_LostFocus()
    Dim ctl As Control
    Dim slctdItem As Variant ' selected item from listbox
    Dim strHClass, strSelection As String
    Set ctl = Forms!frmSiteEdit!lboxHydrologicClass
    For Each slctdItem In ctl.ItemsSelected
    strSelection = ctl.ItemData(slctdItem)
    strHClass = strHClass & strSelection & ","
    Next slctdItem
    Forms!frmSiteEdit!tboxHydrologicClass.SetFocus
    Forms!frmSiteEdit!tboxHydrologicClass = Left(strHClass, Len(strHClass) - 1)
    Forms!frmSiteEdit!lboxHydrologicClass.Visible = False
    End Sub
    -----
    Problem: How to leave the listbox with all items deselected.

    When the textbox receives the focus the listbox is toggled to visible = true

    Once the listbox loses the focus the selected items are assigned to the textbox and the listbox toggled to visible = false but I cant find where to set all items in list box to 'deselected'

    Question 2
    Do I need to have 2 controls working in tandem ?
    Why not just the listbox ? What am I missing ?

    Cheers & thanks in advance for any and all ideas.
    Geof Richardson

  2. #2
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multi Select ListBoxes (Access 97)

    This will deselect all items in a listbox. You'd have to work with the code to see where it would work for you. The listbox will still need the focus I believe.
    Paul
    Dim intX As Integer
    For intX = 0 To lBoxHydrologicClass.ListCount - 1
    lBoxHydrologicClass.Selected(intX) = False
    Next

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Multi Select ListBoxes (Access 97)

    Is there a reason you're doing this with two controls? You have the built-in ItemsSelected property to work with, so what's the point of the textbox? For that matter, why are you toggling the listbox's visibility on and off and wanting to deselect the values?
    Charlotte

  4. #4
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Multi Select ListBoxes (Access 97)

    Hi
    Thanks for that
    All working well.
    Geof

  5. #5
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Multi Select ListBoxes (Access 97)

    Hi Charlotte
    Your questions confirmed that I was barking up the wrong tree.
    I did have a reason for use of two controls but I was into digging holes .. and getting deeper into the mire.
    All fixed now with only one control.

    Cheers & thanks
    Geof

Posting Permissions

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