Using the FORM.VIEW method
Assume that you have a form called "Print Invoices". The form prompts for the starting invoice number (in a control on the form called start_inv ) and the ending invoice number (in a control called end_inv ). The form also has three buttons: "Preview", "Print" and "Cancel".
The following script could be a Global Script, or could be attached to a button on a form.
The script is now paused until the user closes the dialog box. Find out what the last button pressed was using the .LAST_PRESSED() method.
Last_button = :Print_Invoices.last_pressed()
Because the user action of "closing" the dialog only actually hides the dialog, the expression: :Print_Invoices:start_inv.value can read the value of the starting invoice number from the dialog.
Select Case Last_button = "Preview" :report.preview("Invoices", ("inv_no >= :Print_Invoices:start_inv.value) .and. (inv_no <= :Print_Invoices:end_inv.value ")) Case Last_button = "Print" :report.print("Invoices", "inv_no >= :Print_Invoices:start_inv.value .and. inv_no <= :Print_Invoices:end_inv.value ") End select
Now that the report has been printed, close the dialog.
The following script opens the customer information form as a dialog and shows the record whose record number is stored in the variable, recno.
dim shared recno as N filter = "between(recno(), " + recno + "," + recno + ")" form.viewQueried("customer information",filter,"","dialog")
Note that the expression for "filter" will generate an expression like: between(recno(), 23,23). Even though recno is a numeric variable, it can be used 'in the expression for "filter" without having to use the STR() function to transform its type to Character since Alpha Anywhere does automatic type conversions to character.