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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The following code is used to run the QRY_QryCustomerOrd query according to the current customer and toprint the report:-- Click process of BTN_PrintOrder button// Run the query according to the current customeriInitReportQuery(RPT_CustomerOrdReport, NUM_CustomerNum)// Print the reportiPrintReport(RPT_CustomerOrdReport)Parameters <strong>com</strong>ing from edit controlsIn most cases, the parameters passed to a query with parameters are entered by the user in edit controls.In order for your query to be run even if no value was entered by the user, check "NULL if empty" for the editcontrols ("Details" tab of the control description).When this option is checked, if the edit control is empty, the value of the parameter passed to the query willcorrespond to the NULL constant. No error will occur when the query is run: the conditions that depend onthis parameter will be ignored.For example, the SQL code run is:SELECT NameOfItemsFROM NameOfFilesWHERE Item = {Param1}In this example, the table below describes the use of "NULL if empty":Value entered by "NULL if empty" optionSQL code runthe userNo value Option checked SELECT NameOfItemsFROM NameOfFilesNo value Option unchecked SELECT NameOfItemsFROM NameOfFilesWHERE Item = ’’A value is enteredOption checked or unchecked5.3.4 Two methods for passing parameters to a querySELECT NameOfItemsFROM NameOfFilesWHERE Item = ’ValueEntered’Two methods can be used to pass parameters to a query with parameters used in a window, in a page or in acontrol (list box, looper, <strong>com</strong>bo box or table):• pass the parameters in HExecuteQuery.• use the following notation .,, then HExecuteQuery.Note: If the query with parameters is used in a report, the mode for passing parameters changes. See “Usinga query with parameters”, page 214 for more details.Using HExecuteQuery to pass parameters to a queryWhen running a query with HExecuteQuery, the last parameters passed to the function correspond to thequery parameters.The syntax used is as follows: = HExecuteQuery( [, ] [, [, [, …]]])Caution: In this case:• The values of the query parameters must be specified in their initialization order (visible in the queryeditor). Each parameter must correspond to the expected type. The different parameters are separatedby a <strong>com</strong>ma.Part 2: Query editor 217

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

Saved successfully!

Ooh no, something went wrong!