Displaying Value in Unbound Combo Box

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
 
K

Kelvin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top