LPARAMETERS tcTag *** Make sure a valid tag name was passed 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 ENDWITHThe IsTag() function looks like this:
FUNCTION IsTag( tcTagName, tcTable ) LOCAL ARRAY laTags[1] LOCAL llRetVal *** Get all open indexes for the specified table ATagInfo( laTags, "", tcTable ) *** 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, 15 ) > 0 )