Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to limit the range of records in a grid ? 3

Status
Not open for further replies.

seriousfunroger

Programmer
May 9, 2006
3
0
0
US
I would like a grid to only display a group of records in a table which meet the conditions had previously determined.
My table is indexed, I seek the first record which meets my condition, use a do while to count the records meeting the condition, now I want to browse only those records in a grid.
I have tried copying the records to another table which works well until I want to edit the record. Then I am editing a copy of the record, not the original record. I know I could edit the copy and move the changes to the original record, but this all seems very messy and could be avoided it I could limit the
range of records in grid.
 
Filter table
SET FILTER TO ....
Then refresh the Grid
I prefer to use CursorAdapter and then just CursorRefresh() it.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 

Another option would be to create a local view. In its Where clause (the Filter tab in the view designer), specify the condition that you want to apply. Make the view updatable. Then use the view in place of the original table as the record source for the grid.

But Borislav's idea would be simpler.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I tried using set filter to but I have over 7000 records and the time necessary to move from one record to the next in the grid was intolerable.
 
You can try:

INDEX ON myorder FOR mycondition TAG mytag
SET ORDER TO mytag

Then you'll only access records meeting "mycondition."

Jim
 

the time necessary to move from one record to the next in the grid was intolerable.

You can speed up a filter considerably if you create an index on the expression that you are filtering on. You only need to create the index once.

In fact, that's true no matter which method you use for limiting the records in the grid. Whether you use a local view, or a filter, or whatever, you'll get terrible performance if you don't have that index.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I know I could edit the copy and move the changes to the original record, but this all seems very messy

I don't like editting data in a grid but when the users insist then I use this technique of a separate table - I use a cursor instead of a table but it's not as messy as it sounds. Just a case of SCATTERing the fields from the editted record then SEEKing the record in the main table and GATHERing.

The big advantage is that the user is navigating through a grid holding a few dozen records from a local file rather than hopping and skipping through tens of thousands of records across a network connection.

Geoff Franklin
 
It's better to use cursors to display data on grids. If then you want to "filter" the data just issue a new SQL command. I usually use this routine when reloading data to the cursor.

Code:
thisform.grid1.recordsource=""

select data1,data2,data3 from mytable order by data2 into cursor mycursor readwrite 

index on data2 tag myindex &&optional, but useful if you want to make searches

thisform.grid1.recordsourcetype=1
thisform.grid1.recordsource="mycursor"


You make the cursor readwrite so the user can edit the data.
That way you don't mess with anything until you're ready to send an update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top