HOWTO: Use More Than One Table in a Combo or List Box

ID: Q132548

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 6.0

SUMMARY

This article shows by example how to use fields from multiple tables in a combo or list box by placing a SQL SELECT command in the RowSource property.

MORE INFORMATION

Step-by-Step Example

1. Create a new form.

2. Open up the Data Environment and place the Products and Orditems tables

   in it.

3. Select the Combo box or List box tool from the form?s Control toolbar,
   and place a combo or list box on the form.

4. Set the FirstElement property to 1, the NumberOfElements property to 1,
   and the RowSourceType property to 3-SQL Statement.

5. Add a SQL statement such as the following in the RowSource property:

      SELECT DISTINCT(padl(alltrim(orditems.product_id),2," ")) + ;
         "....." + products.prod_name AS prod FROM orditems, products ;
         INTO CURSOR items ;
         WHERE products.product_id = orditems.product_id ;
         ORDER BY prod

6. Run the form, and click the combo box down arrow to open up the list.
   The Product_id from the Orditems table will be the first thing in
   each line item with periods leading over to the product name (Prod_name)
   derived from the Products table.

Additional query words:
Keywords          : kbcode kbnokeyword kbVFp300 kbVFp500 kbVFp600 
Issue type        : kbhowto


Last Reviewed: October 23, 1998
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.