Results 1 to 4 of 4

Thread: Listbox ( one field, multiple columns)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Chase City, Virginia, U.S.A.
    Posts
    2

    Post

    I want to know how to have a listbox that I can display one field from a table, but show it in multiple columns in a listbox. Also this field could contain upwards to 400 records and I probably will need to distribute them evenly throughout the columns in the listbox. Can anyone help me?

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    Gosh that looks complicated just to put columns in a list box!

    What I've done in the past is to use a fixed-pitch font, like Courier New, and simply add spaces between the words so that the different fields in the list are in columns. I use space(maxfieldlength+1 - len(field)) to fill in the gap.

    So it looks something like this:

    data1.recordset.movefirst
    Do until EOF
    l2=""
    l1 = data1.recorset("field1")
    l1 = l1 & space(maxfield1length+1 - len(l1))
    If not EOF then data1.recordset.movenext
    l2 = data1.recorset("field1")
    l2 = l2 & space(maxfield1length+1 - len(l2))
    list1.additem l1 & l2
    data1.recordset.movenext
    Loop

    It's a little cruder I think, and you have to use a fixed-pitch font, but the code is a lot easier to follow!

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    I don't use that API either, I just use vbTab between the fields

    Unfortunately, field sizes may vary, so it'll look a bit sloppy at times

Posting Permissions

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



Click Here to Expand Forum to Full Width