Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Roy Slough
  Where is Roy Slough?
 Potters Bar
 United Kingdom
 Roy Slough
 Tags
Subject: RE: Ordering and Filtering in a grid
Thread ID: 345207 Message ID: 345210 # Views: 56 # Ratings: 1
Version: Visual FoxPro 8 Category: Grids
Date: Sunday, May 20, 2012 5:11:02 PM         
   


Hi Roy,

When you Set Filter, you can or may need to move the record pointer in order to "activate" the filter, especially if the current row before you Set Filter is out of scope afterwards, so that a typical sequence would be
Set Filter To someExpression
Go Top In yourAlias && or "Locate", "Seek()", whatever


In addition, Set Filter is working relatively slowly, especially when the filtered result is being displayed in a Grid or Browse.
So that IMO often SQL "Where" filters are working much better in many cases.

In addition, if you do Set Filter, you may get Error 12 if you are having properties or variables in the Filter expression that my run out of scope:

CREATE CURSOR temp (col1 C(10), col2 I)
INSERT INTO temp VALUES ('one', 1)
INSERT INTO temp VALUES ('two', 2)

LOCAL lcFilter
lcFilter = 'one'
SET FILTER TO col1 = m.lcfilter
BROWSE && works

RELEASE lcFilter
BROWSE && error 12

lcFilter = "'one'"
SET FILTER TO col1 = &lcfilter
RELEASE lcFilter
BROWSE && works

lcFilter = "2"
SET FILTER TO col2 = &lcfilter
RELEASE lcFilter
BROWSE && works





hth
-Stefan

> Hi, I am displaying some records in a grid and I would like the user to change which subset (Filter)
> and then the order in which they are displayed.
>
> On the form I have a combo box selecting which subset (Filter) of records to display
>
>
> SET FILTER TO syscodes.Ccodetype = thisform.cboFilterby.Value 
> SET ORDER to TYPEORDER   && CCODETYPE+STR(ILISTORDER) 
> 

>
> Then on the click event of the column header I have
> N.B I am using CHR(187) + CHR(171) to indicate which sort method is in operation
>
> IF RIGHT(this.Caption,1) = CHR(171)
> 	SET ORDER TO cCodedesc ASCENDING 
> 	this.Caption = "Code Description " + CHR(187)
> ELSE 
> 	SET ORDER TO cCodedesc DESCENDING 
> 	this.Caption = "Code Description " + CHR(171)
> ENDIF 
> Thisform.grdSyscodes.Refresh()
> 

>
> Now Bizzarly the set order to ascending shows all the records in ascending order, but
> the set order to descending only shows one record
>
> What Am I doing incorrect?
>
> Thanks

ENTIRE THREAD

Ordering and Filtering in a grid Posted by Roy Slough @ 5/20/2012 4:00:15 PM
RE: Ordering and Filtering in a grid Posted by Anders Altberg @ 5/20/2012 5:05:39 PM
RE: Ordering and Filtering in a grid Posted by Stefan Wuebbe @ 5/20/2012 5:11:02 PM
RE: Ordering and Filtering in a grid Posted by Roy Slough @ 5/21/2012 3:00:21 PM
RE: Ordering and Filtering in a grid Posted by Stefan Wuebbe @ 5/21/2012 10:49:57 PM