|
![]()
Displaying data related to that shown in a Combo BoxThe first way is to use a Domain Aggregate function, DLookup. Assuming that the combo box, cboData, is based on a table called tblName, and that the RowSource for the combo box is based on two fields from the table, fldPK, an Autonumber field, and fldData, a text field, with the Bound Column set to the first column, which has a width of 0, so that the user won't see it. You can then create a text box that will display another field, fldRelate, for the selected record, by setting the ControlSource of this Text Box to: =DLookup("[fldRelate]","[tblName]","[fldPK]="& Me!cboData) The main problem with using any Domain Aggregate function is that it can be slow, as they don 't use the indexes for a table, but as you can only display 65536 records in a combo or list box it might not be too bad. Another option would be to write your own DLookup replacement, that does use Indexes, which should be faster. The other way of displaying related data from a combo box is to add the extra columns from the table to the RowSource of the combo box, and change the number of columns to reflect the new number of columns, and chenge the ColumnWidth property for the new columns to 0, so that the user doesn't see them. You can then create a new text box on the form, and set the Control Source to: =Me!cboName.Column(2) Which will display the data from the third column in the combo box (note that combo boxes are 0-indexed, so that the first column has a value of 0).
Copyright & Disclaimer | ||||||||||||
| Last modified at 06/06/2006 14:54:53 | |||||||||||||