Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comboboxes - Using Multiple Columns

Combo Boxes

Comboboxes - Using Multiple Columns

by  KenReay  Posted    (Edited  )
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.




Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top