A combo box may display several columns in its drop down list.
The number of columns visible in the combo box dropdown list is controlled by a combination of:
[ul][li]the .Columns property of the combo box[/li]
[li]the width property for each column.[/li][/ul]
Columns with a width value of zero, are present and available in code, but are not visible to the user.
The columns are numbered from the left beginning at zero.
The value returned using =cboMyCombo is the value from column zero.
To return the values from other columns use =cboMyCombo.Column(1), =cboMyCombo.Column(2) ..etc
A common use for this is to allow the user to choose (say) a name from a combo box and to display the associated Address, to achieve this define a combo box as follows:
[ul][li]Name: CboName[/li]
[li]Rowsource: SELECT lngId, strName, strAddress1, strAddress2, strAddress3 FROM tblPeople ORDER BY strName[/li]
[li]Columns: 5[/li]
[li]ColumnWidths: 0;4;4;4;4[/li][/ul]
Define four text boxes (txtAddess1, txtAddress2, txtAddress3, txtAddress4) with properties so:
[ul][li]Enabled: False[/li]
[li]Locked: False[/li]
Set their ControlSource property so
Control ControlSource
TxtAddress1 =cboMyCombo.Column(2)
TxtAddress2 =cboMyCombo.Column(3)
TxtAddress3 =cboMyCombo.Column(4)
Now if you choose a name from the combo box dropdown list, the name will be shown in the combo box control, and the address will be displayed in the textbox controls.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.