What is the purpose of the BOUND COLUMN property of a list in MS Access?

What is the purpose of the BOUND COLUMN property in a list?

+2


source to share


3 answers


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

Note that you cannot use a column name here. Therefore, you are not setting the associated column to the column name, but you must use the column number.

Another problem is that the column number starts at 1 (not zero). Note that OFTEN the length of the 1st column is zero. This allows you to have a list with something like

select PartNumber, PartDescripton from tblParts

      



The list box will display the description of the part, but if you set the bound column = 1, then the list will return PartNumber even though the list displays Descriptions (since you set the length of the 1st column = 0 If you set the bound column = 2 , then the listbox will return a description. Note that you can get any column value from the list with

([lstBox1] .Column)

Note that in the above example, the column function is null based. So 1 = 2nd column

+8


source


This is the dataset column that is used to set the list value. For example, if it is bound to a dataset with a query:

select firstname,lastname,userid from users;

      



then setting the related column to userid (3 in the above example) will result in the user id information being returned as the list value.

+3


source


The related column is the data that the form will save. For example, if you have a list box or combo box that specifies employeeID and employeeName, and you set the bound column to 0, the form will store the employee ID with the selection and insert that value into the appropriate table. You can check what value you are referencing this by 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 related column rule is applied even if the first column is hidden in the form. For example, a user can select "Mike Jones" from a list of employees, but the form will store Mike Jones's Employee ID for data use (this ID can be stored in the sales records table, etc.).

0


source







All Articles