Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Loop in list box (2000 sr-1)

    please adjust the looping to fill the listbox ... i want to use 12 filed

    rs.MoveFirst
    cont = 0
    While Not rs.EOF

    List1.AddItem rs.Fields(0)
    List1.List(1, 2) = rs.Fields(1).Value
    cont = cont + 1
    rs.MoveNext
    Wend

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Loop in list box (2000 sr-1)

    Instead of using a loop and AddItem, I'd set the Row Source Type of the list box to Table/Query, and the Row Source to the table, query or SQL statement on which your recordset is based. That way, you don't have to write a loop. Access will automatically use as many fields as are needed to fill the columns of the list box.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in list box (2000 sr-1)

    tks but not completly understand....

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Loop in list box (2000 sr-1)

    A list box in Access has a Row Source Type property that can be set to one of the following:
    - Table/Query
    - Value List
    - Field List
    If the Row Source Type is Table/Query, you can populate the list box by setting the Row Source property to a table, query or SQL string. Each record will be a row in the list box, and each field will be a column.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loop in list box (2000 sr-1)

    I am very sorry ... have posted qst in Access, but my real prob is in VB classic.
    sorry, move the qs in VB/ VBA, tks for patience.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Loop in list box (2000 sr-1)

    OK. I have moved it to the VB/VBA forum.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Loop in list box (2000 sr-1)

    In VB6 you should use a ListView control instead of a ListBox control. You already know how to populate the columns in a ListView control (see the thread starting at <post:=656,969>post 656,969</post:>).

Posting Permissions

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