[ACCEPTED]-What is the purpose of BOUND COLUMN property of listbox in MS Access?-vba

Accepted answer
Score: 10

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

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

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

select PartNumber, PartDescripton from tblParts

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


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

Score: 4

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

select firstname,lastname,userid from users;

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

Score: 1

A bound column is the data that the form 15 is going to save. For instance, if you 14 have a list box or combo box that lists 13 employeeID and employeeName and you set 12 the bound column to 0, the form will save 11 the employee ID number from the selection 10 and insert that value into the corresponding 9 table. You can test which value you are 8 referencing this using this vba:

Private Sub ComboBoxName_AfterUpdate()
   MsgBox ("bound column is: " & Me.ComboBoxName.BoundColumn & ". value is: " & Me.ComboBoxName.Column(0))'change 0 to whatever number column is bound
End Sub

The bound 7 column rule applies even if the first column 6 is hidden on the form. For instance, the 5 user could select "Mike Jones" from the 4 employee list, but the form is going to 3 save Mike Jones' employeeID for data uses 2 (this ID could be stored in a table of sales 1 records, etc.).

More Related questions