| **Navigation:**  [[clarion 7 faqs.htm|How To's and Troubleshooting]] > How to... >====== How to create a report based on a Browse Query ====== | [[how to create a new menu.htm|{{btn_prev_n.gif|Previous page}}]][[clarion 7 faqs.htm|{{btn_home_n.gif|Return to chapter overview}}]][[how to create a simple assignment expression.htm|{{btn_next_n.gif|Next page}}]] | | || This technique requires two control templates on the browse procedure and an extension template on the report procedure. It also requires a means of passing a value (of the query string) to the report procedure either via a global variable or a passed parameter. The following steps assume that an application containing a Browse procedure and a Report procedure (both utilizing the same file and key) is open. **Declare the Global variable** 1.Open the **Data/Tables Pad**, select the //Global Data// section, and press the **Insert** button and add the following variable: **       GLO:ReportQueryResult STRING(1024)** **       !Note this can be as much as 5k chars)** 2.Press the **OK** button to save the new global variable, then press the **Cancel** button when the //New Column Properties// dialog appears again. **On the target Browse Procedure:** Add the query button control template. 1.Open the Window Designer on the target Browse Procedure. 2.Verify and select the **Control Templates** Pad. 3.Click and drag the //BrowseQBEButton//, to the position where you want the upper left-hand corner of the Query button, and release the mouse. 4.Right-click on the Query button, and select **Actions** from the Popup menu. 5.Press the **QBE Options** Button, and then press the **QBE Class** tab. Make a note of the Object Name. This enables a query on the browse and saves the filter expression we will pass to the report. **Add the BrowsePrint button control template.** 1.Verify and select the **Control Templates** Pad. 2.Click and drag the //BrowsePrintButton//, to the position where you want the upper left-hand corner of the Query button, and release the mouse. **Specify the report to call.** 1.RIGHT-CLICK on the new Print button, and select **Actions** from the Popoup menu. 2.Select the Report procedure to call from the Print Button drop-down list. Press OK to close the Actions dialog. 3.Again, RIGHT-CLICK on the new Print button, and select **Embeds** from the Popoup menu. 4.Highlight the //Accepted// embed, and press the **Insert** button. Highlight Source, and press the Select button. Type the following line of code: **    GLO:ReportQueryResult = QBE****//n//****.GetFilter()** Replace //n// with the appropriate number of the QBE object which you noted earlier. {{notebox.jpg|NoteBox.jpg}} The report MUST use the same key and filter as the browse! **Add the ExtendProgressWindow control template.** 1.Return to the Application Tree, and press the **Extensions** button. 2.Press the **Insert** button. Highlight //ExtendProgressWindow// on the list, and press the **Select** button. 3.Press the Save and Close button {{saveclose.jpg|SaveClose.jpg}} to return to the Application Tree. 4.Press the **Embeds** button, and navigate to the ThisReport.Open in the LocalObjects branch of the embed tree. Embed the following code in the CODE section at a Priority of 5000: **IF GLO:ReportQueryResult** **    ThisReport.SetFilter(GLO:ReportQueryResult)** **    ThisReport.ApplyFilter()** **    GLO:ReportQueryResult = ''  !Clear the var** **END** Exit back to the Application tree saving your work when prompted.