Query by Form (QBF) is great.  It's simple to use, and extremely powerful.  Virtually all of my customers (some of whom know very little about computers or programs) can use it to get meaningful results.

However, as with many programs, there are some cases where the filter or sort order of the query is complicated enough to make QBF cumbersome.  In most of those cases, I usually design the query, and prompt the user for needed information.  But this deprives the user of the flexibility of QBF.  What to do??

Well, I came up with a solution, thanks to another user on the Alpha Message Board.  I had a case where the user had all kinds of different ways that they wanted to filter their records, but always wanted to sort them the same way.  And, the sort order was quite complicated, in that it required more than just clicking on several fields in the Sort screen of QBF.

So, I designed a query that was really just the complex sort order.  Then I attached the script to a button, and instructed the user to run their QBF, and then click on the button.  The relevent part of the script is:

tbl= table.current()
u_qbf = tbl.index_primary_get().filter_get()
query.order = "<ORDER_EXPRESSION>"
query.filter = u_qbf

where <ORDER_EXPRESSION> is the complex expression I used to define the order.

Here's what happens:  When the user runs QBF, the primary index of the table becomes the result of the user's query.  I define the variable u_qbf as the filter of that primary index (filter_get()).  Then, in the fourth line of the script, I use the filter u_qbf to define the query's filter.

In effect, my script is running exactly the same query that the user ran, but is also adding the sort expression.  (Note that the same type of thing could be done if the user wants to define the sort order, but the filter is complicated).

The result is a program that permits great flexibility combined with complex filter or sort criteria.  What more could anyone ask for??



Do you have a tip or trick that makes designing easier, or data entry simpler?  If so, please visit Tips & Tricks (http://www.alphasoftware.com/tips/default.asp) to submit your idea.