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
- Create a new form.
- Open up the Data Environment and place the Products and Orditems tables
in it.
- Select the Combobox or Listbox tool from the form s Control toolbar, and
place a combo or list box on the form.
- Set the FirstElement property to 1, the NumberOfElements property to 1,
and the RowSourceType property to 3-SQL Statement.
- 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
- 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.
|