Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL
Expertise: Beginner
Mar 24, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Dependent values

I want to create a list box that will contain values based on the value of another list box. How can I accomplish this?

A list box is populated whenever the Translation property for the list box is set. To populate a list box based on the value of another list box, set the Translation property of the second list box in the PostChange() method of the first list box.

If the first list box is called lstSource, and the second is called lstPopulate, the lstSource box contains a department number, lstPopulate contains the NAME and ID of employees of the selected department and the Datatype of the two list boxes is "String," the code in the PostChange() method of lstSource would read:

lstPopulate.Translation = "= SELECT NAME, ID FROM EMPLOYEE WHERE DEPT = '" & &
        lstSource.Value & "'"

Notice that you must insert the Value of the lstSource list box in single quotes, since the SQL statement will need the actual value rather than a bind variable.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date