First, are these actually labels or textboxes? Assuming labels, see if the
following example helps.
In the AfterUpdate event of the combo box:
Me.lblAdd.Caption = CStr(DLookup("[FieldName]", "[TableName]", "[FieldName
Associated with Combobox]=" & Me.cbTermNm))
Adjust the field name to match the field appropriate for the label being
filled. The syntax at the end assumes a number is returned by the combo box,
if it is text, adjust the line as follows:
Me.lblAdd.Caption = CStr(DLookup("[FieldName]", "[TableName]", "[FieldName
Associated with Combobox]='" & Me.cbTermNm & "'"))
The newsreader will probably wrap the lines due to their length, it should
be one line. If there are apostrophes in the value returned by the combo
box, another modification will need to be made, let me know if that is the
case. The value of the combo box is the value in the Bound Column of the
combo box when you've made a selection.
Another option is to add the other items to additional columns in the combo
box. You could set the width of those columns to zero to hide them, if you
wish. All visible columns will be displayed when the drop down is open, but
only the first visible column will be displayed once the selection is made.
You could then simple refer to the other columns in the combo box to get the
associated values.
Example:
Me.lblAdd.Caption = Me.cbTermNm.Column(1)
The column number above is zero based, so 0 is the first column, 1 is the
second, 2 is the third, etc. If the control is a textbox instead of a label,
you could set the Control Source of the textbox to point to the appropriate
column in the combo box and it will automatically update when the selection
is made, no code needed. If you want it to look like a label, you could play
with the formatting of the textbox (including the Locked and Enabled
properties) to make it look like a label.
--
Wayne Morgan
MS Access MVP
Tony said:
I have tried these out and I must be missing something.
My form is called frm_Dest
My combobox is called cbTermNm
My Lables are lblAdd, lblCt, lblSt, lblZip
When I select my Terminal Name from cbTermNm I want the labels to populate
the missing info from the table it reside in on the update.
For some reason I cannot get them to work. Either Monday is really
getting
to me already or I just don't get it.
Thanks