Mastering PowerBuilder

HomePrevious Lesson: Course 3:: Session 24 :: Page 330
Next Lesson: Course 3:: Session 24 :: Page 350
Query Service

Similar to the eny PFC service, you need to enable query service if you wish to use the query service. Write the following code in the pfc_PostOpen event:

dw_product.of_SetQueryMode( TRUE )

This basically creates the query mode. To put the DataWindow in the query mode, you need to write the following in the ue_query of the w_product_master window:

dw_product.inv_querymode.of_SetEnabled( TRUE )

Similar to the way we turn off the query mode using the Modify() function, you need to put the DataWindow in the normal mode before you retrieve the data. So, add the following code to the "ue_retrieve" event of the w_product_master window before the Retrieve() function:

dw_product.inv_querymode.of_SetEnabled( FALSE )

This gives you the same query mode functionality that we normally use. No extra amazing functionality like sort service. By default, PowerBuilder doesn’t remember the previous query. For example, you make a query in the DataWindow at run-time and retrieve the data. Now, if you go to the query again, you will the blank lines. However, with PFC, you can display the previous query. Write the following code after the of_SetQueryMode() function in the pfc_PostOpen event:

dw_product.inv_QueryMode.of_SetResetCriteria (False)

Now, run the application and see how it works. Comment the line just above this line and run the application one more time and test it again.

After entering the query in the query mode, if the user close the window without retrieving the data, PFC prompts for saving the changes. Write ib_DisableCloseQuery = TRUE before turning on the query mode in the ue_query mode. Set to FALSE in the ue_retrieve event of w_product_master before retrieving the data.

HomePrevious Lesson: Course 3:: Session 24 :: Page 330
Next Lesson: Course 3:: Session 24 :: Page 350