>VFP right! But it does not seem to work. When I set the order to the index which = "S" $ alltrim(myfield). I still get all the records when I browse. Am I doing something wrong?
Perhaps - although I never used filtered index myself.
But a quick test shows that it works.
First precaution: You have to distinguish the index expression from the filter expression.
Second precaution: You have to make sure the index is really selected (SET ORDER).
I have a sample table, Field2 contains arbitrary numeric data.
To show only records with even numbers, I created an index interactively (MODIFY STRUCTURE) as follows:
To the right of Field2 (in the "Fields" tab), I selected a regular index.
Then, I went to the "Indexes" tab. The previous step created an index with Order = "Ascending", Name = "FIELD2", and Expression = "field2".
I added the following clause in the "Filter" column: Field2%2=0. (When returning to MODIFY STRUCTURE later, VFP had changed this to: MOD(Field2,2)=0. No big deal.)
In the command window:
SET ORDER TO FIELD2 && This is the name of the index
BROWSE
... indeed shows me only the records with even numbers, as expected.
The equivalent command, to create the index through a command, should be:
INDEX ON field2 TAG field2 FOR Field2%2=0
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)