Click to See Complete Forum and Search --> : Listbox ( one field, multiple columns)
surveyor88
Jan 15th, 2000, 10:55 AM
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?
Clunietp
Jan 16th, 2000, 12:00 AM
Multiple columns in a listbox:
http://support.microsoft.com/support/kb/articles/Q141/0/26.asp?LNG=ENG&SA=ALLKB
HarryW
Jan 16th, 2000, 07:14 PM
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! :)
Clunietp
Jan 16th, 2000, 10:55 PM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.