×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

grid instead of browse

grid instead of browse

grid instead of browse

(OP)
hello,

i followed many programmers suggestion to use grid instead of browse.
but i have a question.
how can i show in the grid only some of the records depending on a condition.
do i use SET FILTER? isn't that slow if you have large number of records?

thank you

RE: grid instead of browse

Yes, you can use SET FILTER. And yes, it does tend to be slow if you have a large number of records.

Another option is to create a cursor containing just the records that you want to show. You can do this with SQL SELECT command. For example:

CODE -->

SELECT * FROM MyTable WHERE <some condition> INTO CURSOR MyCusor 

The set the grid's RecordSource to point to the cursor.

This is efficient, but it has the drawback that you can't easily use the grid to edit the underlying table. If the user edits the grid, the edits go to the cursor, not the table. You would have to write additional code to deal with that. But if you just want to use the grid to display data and to let the user navigate a table, this is the best approach.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: grid instead of browse

(OP)
thank you Mike,

i thought of sql select but the data needs to be edited.
what are the options to edit the data when using sql select?

RE: grid instead of browse

CODE

USE a.dbf
BROWSE FOR condition 
is not faster than

CODE

USE a.dbf
SET FILTER TO condition
BROWSE 

And likewise displaying in a Grid.

Because, as I already said on several occasions, a browse is a grid.

That also means all you read about SET FILTER making grids slow is also true for BROWSE FOR.

SET FILTER can get sluggish. I also wrote about that, many years ago. But that typically only begins with 10,000 records or more. Today it can even be better. And through the grid's optimize property a very specific optimization is also turned on for grids. By the way, it's nevertheless .F. by default.

The absoluteƶy clean way is to go for a 3 tier architecture, never directly binding grids or browse to DBF files, but using updatable views or cursoradapters.
But as long as you even haven't tried to SET FILTER you're worrying at the wrong stage of your development. The recommendation still is and always will be premature optimization is hindering you to get to your goal. Bottlenecks appear at places you don't necessarily expect them.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close