Question Query: how to change using a trigger (GUI)

wa4qms

New Member
Needing some help in understanding what I need to do if I want to change a QUERY that is used in a browse. But first here is the layout. I have a C-Win that has the default-frame, a Frame-A and a Frame-B, Both are the same size and are not connected thru any handles. Frame-B contains the browser. Here is the code to open it:

OPEN QUERY BRW-Sector FOR EACH tt-load.

So to point me off into the right direction, I’d like to add a trigger that could change the code to read something like:

OPEN QUERY BRW-Sector FOR EACH tt-load where tt-load.xxx = <some value>.

So I thinking I’d close the existing browse, QUERY-PrePare() with the new code, but then what?
The goal here is to allow the end user to limit the number of records in the browse. These things are massive in size, maybe as much as 50k rows, so the user may want to look at column X if the difference <> 0, or whatever.
And I am thinking that if using a temp-table, only selecting certain ones, are non-selected rows in any danger of being affected? In other words, I have 3 editable columns and one that calculates on any change to the row. If I make changes there, then revert back to original QUERY, will my changes still be there?

I guess I should also add that the temp-table is not loaded until the user selects the ‘sector’ file to use / update. There are 6, and each contain identical number of fields.

Any help steering me into the right direction would be greatly appreciated.

Dennis
WA4QMS
 

Osborne

Active Member
For the trigger or limiting records you can do something like this:
Code:
DEFINE VARIABLE hBrowseQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE vQueryString AS CHARACTER NO-UNDO.

hBrowseQuery = BROWSE BRW-Sector:QUERY.

ON triggerChange DO:
   vQueryString = "FOR EACH tt-load".
   IF whatever THEN
      vQueryString = vQueryString + " where tt-load.xxx = " + QUOTER(<some value>). /* If character field ensure the value is in quotes */
   hBrowseQuery:QUERY-PREPARE(vQueryString).
   hBrowseQuery:QUERY-OPEN().
END.

Regarding this:
I have 3 editable columns and one that calculates on any change to the row. If I make changes there, then revert back to original QUERY, will my changes still be there?

Yes, any changes made to rows will be reflected if you revert back to the original query. It you want to prevent this then set the browse to NO-ASSIGN and changes will not be saved to the temp-table/database table where you made the change.

You may find this useful for working with temp-tables in a browse - search for 100 - Building updates into an application:

 

Attachments

  • Handbook.png
    Handbook.png
    11.2 KB · Views: 6
Last edited:
Hello,
If I understand well your question there is for me two solution:
1. You think of all the filter possible and you create them as fill-in, radio button, combo box etc... and you build your query around them
2. You work with dynamic querys and dynamic temp-table.

Best Regards,
 

wa4qms

New Member
Thanks for all the info, and it just got worst! (LOL), I'll give those a try, and I like that I may be able to build from a radio-set or whatever. I hope that I can place the values on the default-frame as space is an issue.
 

wa4qms

New Member
Whatever is your solution you will always have a space issue with this kind of work.
So true, but what I did find is that I can add on the c-win ribbon a drop down that will work just fine. I have plenty of space there. Actually, two right now, one for filter selection, the other for sort. And there's always the popup option which I used with another company years ago. Thanks for following
 

wa4qms

New Member
So far, working good. For sorting, the drop down will pass the field name to a trigger with the following type of code: on select of the sub-menu do routine for that, i.e. ASSIGN cSort = 'xxxxx'
then
Run IP-BRSort
(input cSort). Or that's the plan.
1668183049901.png
 
Top