How To Use More Than One Table in a Combo or List Box

Last reviewed: October 18, 1996
Article ID: Q132548
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.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 Combobox or Listbox 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 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 reference words: 5.00 3.00 VFoxWin
KBCategory: kbtool kbprg kbcode
KBSubcategory: FxtoolDk


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 18, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.