Populating text box on a form when item is selected in combo box


Posted by Gary on January 03, 2002 5:40 AM

This is driving me crazy. I have a form that allows the user to select an item by number. When the item is selected I want to see the associated description of that item in a textbox (or other type of control) appear on the form so the user knows they selected the appropriate item. Any ideas?

Thanks a million. . .

Posted by Paul N on January 03, 2002 7:01 AM

I am presently doing that in an application I developed. When they select the number, I use the number as a lookup index and retrieve the description from a hidden area that populates the text box...



Posted by Joe Was on January 03, 2002 9:32 AM

Sub myResult()
Worksheets("Sheet1").Select
myFound = Application.WorksheetFunction.VLookup(Range("D1"), Range("A:B"), 2, False)
MsgBox myFound
End Sub

If you build a table on any sheet in any column, one column has the code the other the description then the above VB code will pull the description of a code value and put that description into a MsgBox.

For the code above: A1 down is the code values, B1 down is the description of the code value as text.

D1 is a cell on a worksheet that has a dropdown list of all the code values. Or a input box or a cell. The user selects or enters the code value then runs the macro. The MsgBox displays the "Description of the Code Value" entered. JSW