Results 1 to 8 of 8
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Listbox - Select All (A2K SR1)

    I have a multi select listbox whose values change based upon other combo box and listbox selections made on a form. After the values of the multiselect listbox are updated, the user selects one or many listbox fields to generate a report.

    After the listbox is updated, I would like the listbox to always highlight all entries so the user does not have to select them. (I.e., the form view would show all listbox fields highlighted after the listbox has been updated.) The user would select less fields if necessary.

    Is there a way to do this in the After Update event of a multi select listbox?
    Regards,

    Gary
    (It's been a while!)

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

    Re: Listbox - Select All (A2K SR1)

    Forgive me, but it doesn't make sense to say that after the listbox is updated, you want to select all the entries. In that case, there's no point in the user updating the listbox. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    Charlotte

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox - Select All (A2K SR1)

    You can use :
    <pre>Dim x As Integer
    For x = 0 To Me.MyList.ListCount
    Me.MyList.Selected(x) = True
    Next x</pre>

    But don't forget that the user has to use CTRL Click to deselect an item, otherwise all selections will be deselected.
    Francois

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Listbox - Select All (A2K SR1)

    Hmmm, Now I am confused....

    Here is how the form works. The form contains a combo box, Listbox1 (Not Multi Select), and Listbox2 (Multi Select).

    The user selects a value from the Combo box. Based on the combo box selection made, the values in listbox 1 change. The user then makes a selection in Listbox 1 which causes the values in Listbox 2 to change.

    The user then selects one, many, or all fields in listbox 2 and executes a report based on the values selected.

    Basically, In combo box1, the user selects a Clin. Each Clin has one or many Control Accounts. After selecting a Clin, all control accounts for the Clin are shown in Listbox 1. The user then selects a Control Account in Listbox 1 which causes Listbox 2 to show all WBSID's associated with the Control Account Selected. The user then selects one, many, or all WBSID's to use as the dataset for a report. The user has requested that the listbox show all values as the selection after the listbox is updated and let the user select less values if they want.

    Whether or not this makes sense doesn't matter to the developer (me) as I need to keep the user happy....

    Any ideas, or should I just tell them to highlight all of the entries in the listbox to create the report?
    <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>
    Regards,

    Gary
    (It's been a while!)

  5. #5
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Listbox - Select All (A2K SR1)

    Thanks Francois,

    I will give this a try.
    Regards,

    Gary
    (It's been a while!)

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Listbox - Select All (A2K SR1)

    BTW, how did you set up your query to select all the entries marked by the user in the listbox?
    Pat

  7. #7
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Listbox - Select All (A2K SR1)

    The following is the code used to get the data selected in the listbox. The code is launched from a command button. The code selects the listbox values as the recordset to work with and also updates TABLE - WBS LIST BOX SELECT to hold the data as well for processing.

    Private Sub Command22_Click()

    ' INSERT SELECTED DATA FROM LISTBOX INTO TABLE.TABLE - WBS LIST BOX SELECT
    Dim ctl1 As ComboBox
    Dim ctl As ListBox
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim VarItem As Variant
    Dim WBSID As String, temp As String
    Dim stDocName As String

    ' Set ctl to the name of the Multi Select Listbox
    Set ctl = Me!SELECTWBS

    'Exit Subroutine if the User does not select anything in the listbox
    If ctl.ItemsSelected.Count = 0 Then
    MsgBox "Please select one or more WBSIDs before pressing the CREATE REPORT Button"
    Exit Sub
    End If

    ' Start process to populate table with items selected.
    ' Table - WBS LIST BOX SELECT holds data Selected in the Listbox

    ' Delete all existing items in the table
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "DELETE-TABLE_WBS_LIST_BOX_SELECT"
    DoCmd.SetWarnings True

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordSet("SELECT [TABLE - WBS LIST BOX SELECT].WBSID FROM [TABLE - WBS LIST BOX SELECT]")

    'Loop through the items selected in the listbox

    For Each VarItem In ctl.ItemsSelected
    With rst
    .AddNew
    !WBSID = ctl.Column(1, VarItem)
    .Update
    End With

    Next VarItem

    rst.Close
    Set ctl = Nothing
    'Set dbs = Nothing

    ' END INSERT LIST BOX DATA INTO TABLE
    Regards,

    Gary
    (It's been a while!)

  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Listbox - Select All (A2K SR1)

    Thanks for that !!

Posting Permissions

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