Woody,
In forms, sorting is best handled by changing the current index. Create secondary indexes that sort your table in the various orders you want to supply and then either use the Record | Filter dialog to select the desired index in the Order By list near the bottom, left of the Filter dialog.
(Yes, it's a bit odd to be selecting index order from the Filter dialog.)
You can also add code to switch Indexes on the fly. For example, here's a very basic approach:
Code:
method pushButton(var eventInfo Event)
var
strIndex String
endVar
const
USERCANCEL = "{N/A}"
endConst
switchMenu
case "Order Number" : strIndex = ""
case "Customer No" : strIndex = "Customer No"
case "Oldest Orders" : strIndex = "SaleDate"
case "Newest Orders" : strIndex = "SaleDateDesc"
case "Order Total" : strIndex = "TotalInvDesc"
otherwise : strIndex = USERCANCEL
endSwitchMenu
if strIndex <> USERCANCEL then
Orders.switchIndex( strIndex, Yes )
endIf
endMethod
This is based on the
Orders sample table. (I've added three secondary indexes to the ones that are already created.) The code is taken from the pushButton event on a button, displays a menu of choices, and changes the active index when the user selects on of the menu commands.
This example also assumes there's a TableFrame on the form named Orders. (There's also a tCursor based approach that can be far more efficient in a networked environment.)
There are several different ways you can allow this, but this is one of the most flexible.
Be aware, though, that this changes the properties of the form. If your users are working with undelivered forms (e.g. the .FSL files), it's possible they'll be prompted to save the form after switching the indexes. If they are, change the IF block as follows:
Code:
if strIndex <> USERCANCEL then
Orders.switchIndex( strIndex, Yes )
DesignModified = No
endIf
Hope this helps...
-- Lance