LPARAMETERS tcTag *** Make sure a valid tag name was passed IF ! EMPTY( tcTag ) WITH This *** Make sure it really is a tag for the grid's RecordSource IF IsTag( tcTag, .RecordSource ) lnRecNo = RECNO( .RecordSource ) *** Go ahead and set the order for the table SELECT ( .RecordSource ) SET ORDER TO ( tcTag ) .SetFocus() IF lnRecNo # 0 GO lnRecNo IN ( .RecordSource ) ENDIF ENDIF ENDWITH ENDIF
FUNCTION IsTag( tcTagName, tcTable ) LOCAL ARRAY laTags[1] LOCAL llRetVal *** Did we get a tag name? IF TYPE( 'tcTagName' ) # 'C' *** Error - must pass a Tag Name ERROR '9000: Must Pass a Tag Name when calling ISTAG()' RETURN .F. ENDIF *** How about a table alias? IF TYPE( 'tcTable' ) = 'C' AND ! EMPTY( tcTable ) *** Get all open indexes for the specified table ATagInfo( laTags, "", tcTable ) ELSE *** Get all open indexes for the current table ATagInfo( laTags, "" ) ENDIF *** Do a Case Insensitive, Exact=ON, Scan of the first column of array *** Return Whether the Tag is Found or not RETURN ( ASCAN( laTags, tcTagName, -1, -1, 1, 7 ) > 0 )And this code in the Header's Click method:
WITH This.Parent IF PEMSTATUS( .Parent, 'SetOrder', 5 ) .Parent.SetOrder( JUSTEXT( .ControlSource ) ) ENDIF ENDWITH