ListBox Defualt Value (All Selected)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ChaseCox
    Contributor
    • Nov 2006
    • 293

    ListBox Defualt Value (All Selected)

    Long Time no Post,

    I am working on a new Access form and I would like to utilize List Boxes.

    I currently have my list box populated with values from a table. The list box is set up for Multiple Selections.

    When the form loads I would like to have all of the items in the List Box be selected. Is this possible?

    For example if I had the Following items in my list box:
    Dog
    Cat
    Fish
    Turtle

    When the form loads I would like to see that all of these items are selected, so that if I reference the list box from a query, it will pull all of the values.

    Thanks for the help.

    -Chase
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by ChaseCox
    Long Time no Post,

    I am working on a new Access form and I would like to utilize List Boxes.

    I currently have my list box populated with values from a table. The list box is set up for Multiple Selections.

    When the form loads I would like to have all of the items in the List Box be selected. Is this possible?

    For example if I had the Following items in my list box:
    Dog
    Cat
    Fish
    Turtle

    When the form loads I would like to see that all of these items are selected, so that if I reference the list box from a query, it will pull all of the values.

    Thanks for the help.

    -Chase
    To have all the Items in a List Box named List1 on the Active Form, copy and paste the following code to the Form's Open() Event:
    [CODE=vb]Private Sub Form_Open(Cance l As Integer)
    Dim intCounter As Integer

    For intCounter = 0 To Me![List1].ListCount - 1
    Me![List1].Selected(intCo unter) = True
    Next
    End Sub[/CODE]

    Comment

    • ChaseCox
      Contributor
      • Nov 2006
      • 293

      #3
      Thanks, that worked like a charm. I really appreciate the help.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by ChaseCox
        Thanks, that worked like a charm. I really appreciate the help.
        That's what we are here for.

        Comment

        Working...