Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching a table and jumping to the record
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01018885
Message ID:
01018891
Views:
10
Ways to filter the results would include either create a SQL select statement that includes the criteria as part of the where clause or using SET FILTER TO on your data set (be advised that this latter suggestion should only be used on relatively small result sets).

As to searching, the fastest way to find a record for a particular field is to have an index on that field and use SEEK.

What's the best and quickest way to do all of this? Well that really depends much more than you have provided in your post, but SQL Statements for the filtering of data and SEEK for searching are good things to shoot for.

Jumping to the record on the main form...
If you've defined a primary key for the table being searched then you can send that back to the main form. This can be done a variety of ways, but probably the easiest is to add a Return MyPrimaryKey to the unload event of the secondary search screen... and call the secondary search screen to a variable from the main screen, such as: Do Form MySearch To MyVariable. Now, when MySearch form is released MyVariable will have the value of the Primary key and you can just search for it in your dataset on the main form using SEEK and then refresh your form to show new record.

Or, if your search for has a default data session then you can just move the record pointer right on your secondary search screen

There are other ways to do this, many in fact, but here again these are probably the most common and simplistic.

>I have a form which is bound to a table. When the user clicks on my search button it pops up with another form allowing the user to search on 5 different fields (each field is within the table). I am after some advice as to what is the best and quickest way to search the table? The user may only search on one field, how do I handle it if the user decides to enter information in 3 of the fields to narrow the search results. My search basically needs to handle upto five fields?
>
>In addition how can I jump to the record on my main form from the results of the search?
>
>MAny Thanks
Previous
Reply
Map
View

Click here to load this message in the networking platform