How to do this depends on if the control to populate (Destination Field) is Bound or Unbound.
If it is Bound, then put some code like this in the AfterUpdate Event for the ComboBox control:
- Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & me.ComboBox.Value & "")
-
or
-
Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & Me!FieldSelectedinComboBox & "")
If the Destination Field is Unbound, the easiest way I've found it so put the DLookup into the Control Source property of the Destination.
- =DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & [FieldSelectedinComboBox] & "")[/
then you'll need to add a Requery for the Destination Field in the Combobox's AfterUpdate event and the FormCurrent Event:
- Private Sub cboSourceComboBox_AfterUpdate()
-
Me.txtDestinationField.Requery
-
End Sub
-
Private Sub Form_Current()
-
Me.txtDestinationField.Requery
-
End Sub