tags:

views:

681

answers:

2

What is the purpose of BOUND COLUMN property of listbox?

+2  A: 

It's the column of the data set that is used to set the value of the listbox. For example, if it's bound to a dataset with the query:

select firstname,lastname,userid from users;

then setting the bound column to userid (3 in the above example) will cause the user ID information to be returned as the listbox value.

paxdiablo
The bound column is the column that will be returned as the listbox value, but not necessarily the column(s) that is displayed by the listbox, that is controlled by setting column widths, in the above example it would be normal to set the bound column to 1 and the column widths to, say, 0cm;2cm in order to hide the ID from the user.
Remou
Thanks, @Remou, updated to fix.
paxdiablo
Bound column is not zero based :)
Remou
I am constantly annoyed by the inconistencies in VBA and Access with regard to 0- and 1-based collection indexes. With Arrays, you get the option to set that, but by default, they are 0-based, while Access collections are all 0-based, but custom collections are 1-based. Grrr. I'm constantly screwing these up.
David-W-Fenton
+3  A: 

The bound column is a number that represents what column from the row source will be used to set the value of the Control Source (if the list box is bound).

Note that you can’t use a column name a name here. So you don't set the bound column to a column name, but you must use a column number.

Another issue here is that the column number starts at 1 (not zero). Note that OFTEN the 1st column length is set to zero. That allows you to have a list box with something like

select PartNumber, PartDescripton from tblParts

The list box will display the part description, but if you set the bound column = 1, then the listbox will return the PartNumber despite the fact that the listbox is displaying Descriptions (since you set the length of the 1st column = 0. If you set the bound column = 2, then the listbox will return description. Note that you can grab any column value from the list box by using

([lstBox1].Column)

Note that in the above, the column feature is zero based. So, 1 = 2nd column

Albert D. Kallal
I would've had PartID as the first column in that query. Minor quibble though.
Tony Toews