Displaying Value in Unbound Combo Box

  • Thread starter Thread starter DJ
  • Start date Start date
D

DJ

I have an unbound ComboBox (LastFirst) and a bound TextBox
(PersonID) on a form. I have a query (qryPe_Calculated)
that has 2 fields (PersonID and LastFirst). As each
record is displayed I want the value in the ComboBox to
change based on the value in the TextBox. The following
code appears to be getting the value because the
Debug.Print returns the correct value. But the displayed
value in the ComboBox does not change. How do I get the
ComboBox to display properly? Thanks for your help.

Private Sub Form_Current()
Me!LastFirst = DLookup("[LastFirst]",_
"[qryPe_Calculated]", "[PersonID] = "_
& Me!PersonID)
Debug.Print Me!LastFirst
End Sub
 
You have to remember that a combo box stores what is in the bound field. If
you assign it a value that is not the correct bound column it will still
store that value, but it won't show you. Change your code to

Me!LastFirst = DLookup("[PersonID]",_
"[qryPe_Calculated]", "[PersonID] = "_
& Me!PersonID)

Kelvin
 
Back
Top