To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

             
HOME
TOPICS
News & Notes
Learn Alpha Five
Tips & Tricks
Tech Corner
CONTENTS
LOTS of News This Month
Interview with Susan Bush, author of Alpha Five Made Easy, The Basics and More for Version 4.5
Alpha Four to Alpha Five - Chapter 2
Improve the Appearance of Forms in Alpha Four
Combine Query by Form with Scripting
Micro-adjust Objects on Forms, Reports
Guaranteed 1-Hour Guide to Becoming a Query Filter Expert
Version 5 of Alpha Five shown at Alpha Five Developers' Conference - WOW!
Alpha Four to Alpha Five Seminar
Alpha Five Presenters Wanted!
User Groups
Alpha Referral Program
Combine Query by Form with Scripting
by Bill Warner

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.
[PRINTER FRIENDLY VERSION]
Powered by iMakeNews.com