Question:
I want to create a list box that will contain values based on the value ofanother list box. How can I accomplish this?
Answer:
A list box is populated whenever the Translation property for thelist box is set. To populate a list box based on the value of another listbox, set the Translation property of the second list box in thePostChange() method of the first list box.
If the first list box is called Notice that you must insert the Value of the lstSource
, and the second iscalled lstPopulate, the
lstSource
box contains adepartment number, lstPopulate
contains the NAME and ID ofemployees of the selected department and the Datatype of the two listboxes is “String,” the code in the PostChange() method oflstSource
would read:lstPopulate.Translation = “= SELECT NAME, ID FROM EMPLOYEE WHERE DEPT = ‘” & & lstSource.Value & “‘”
lstSource
list box in single quotes, since the SQL statement will need the actualvalue rather than a bind variable.