Compartir a través de


How to: Display Query Results in a Window

If you want to display the results of your SELECT - SQL statement, you can send the results to a window. The Browse window is the default destination for query results and you don't need to include a destination clause. You can also send the results to the main Visual FoxPro window or another active window.

To display results in the main Visual FoxPro window

  • Use the TO SCREEN clause of a SELECT - SQL statement.

To display results in another active window

  • Define a window, show it to activate it, and then run a SQL query or other command that displays results in a window.

This code example shows the definition for a temporary window titled "Top Customers" that displays the names of companies with more than $5,000 in total orders for the year.

Displaying query results in a window

Code

Comment

frmMyForm=createobj("form")
frmMyForm.Left = 1
frmMyForm.Top = 1 
frmMyForm.Width = 130
frmMyForm.Height = 25
frmMyForm.Caption = "Top Customers"
frmMyForm.Show

Create and start a temporary window object.

SELECT customer.company_name,;
  SUM(orders.freight) ;
  FROM tastrade!customer,
  tastrade!orders ;
  WHERE customer.customer_id =
  orders.customer_id ;
  GROUP BY customer.company_name ;
  HAVING SUM(orders.freight) > 5000 ;
  ORDER BY 2 DESC

Enter a SELECT - SQL statement.

See Also

Tasks

How to: Run Queries (Visual FoxPro)

Reference

SELECT - SQL Command

Other Resources

Setting Query Output Destinations