13.07.2015 Views

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

To use the result of the query in a control (other than a list box, <strong>com</strong>bo box, looper or table):1. Open the window or the page where a control associated with a query must be added.2. Create the control associated with the query.3. Display the description window of the control ("Description" from the popup menu).4. Display the "Link" tab in the description window of the control.5. Select the item to display in "Linked item".6. Validate. The created control will display the information <strong>com</strong>ing from the associated query.7. Enter (if necessary) the following code line in the initialization process of the control. This code line isused to initialize and run the query, and to display the result of the query in the current control.HExecuteQuery()Note: When creating a table control associated with a query, you can:1. Select the query in the "Project explorer" pane.2. Perform a "Drag and Drop" toward the window. A table associated with the query is automatically createdin the window or in the page.4.2.3 Query in a reportA query can be used as data source for a report. The report will display the records selected by the query.See “Report based on a query”, page 45 for more details.Tip: You have the ability to create a report from the current query directly: on the "Query" pane, in the "Filelink" group, click "Create a report".4.3 Running the query and handling the result with the WLanguagefunctionsThe result of a query is not necessarily displayed in a report, in a window, in a page, ... This selection can alsobe used in programming.Most of the HFSQL functions (browse, search, read, …) can be used both on data files and on the result of aquery. To use these functions on a query, the query must be run beforehand (HExecuteQuery).For example, the Customer34 query selects the customers whose zip code starts with 34. The PrintCustomerprocedure is used to print a proforma invoice for each customer. The following code is used to browse theresult of the Customer34 query and to print an invoice for all the selected customers.// Run the queryResExecute = HExecuteQuery(Customer34)// Error while running the query?IF ResExecute = True THEN// Browse the result of the queryFOR EACH Customer34// Print an invoice for each recordPrintCustomer(Customer34.CustomerLName, Customer34.CustomerFName, ...Customer34.CustomerAddress, Customer34.CustomerZIP, ...Customer34.CustomerCity)ENDELSE// Display the error messageError("The query was not run.")END210Part 2: Query editor

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!