Microsoft KB Archive/125791

{| = PRB: KEYMATCH Ignores SET DELETED and SET FILTER Settings =
 * width="100%"|

ID: Q125791

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.6, 2.6a
 * Microsoft FoxPro for MS-DOS, versions 2.6, 2.6a
 * Microsoft FoxPro for Macintosh, versions 2.6, 2.6a

SYMPTOMS
The KEYMATCH function added to FoxPro in versions 2.6 and later does not adhere to the settings of SET DELETED or SET FILTER.

CAUSE
The FoxPro versions 2.6 and 2.6a for Windows style help file states that KEYMATCH; "Searches an index file or index tag for an index key and returns true (.T.) if the index key is found." The SET FILTER and SET DELETED commands only affect the table, not the index. Therefore, KEYMATCH will not adhere to these settings.

RESOLUTION
For KEYMATCH to acknowledge the settings of SET DELETED or SET FILTER, place the FILTER expression and DELETED setting in the index itself.

For Example, unless the same conditions of the SET FILTER expression and SET DELETED ON are added to the index, the following code will not give the desired results using the KEYMATCH function. This example is set up to return a .T. using the Customer table where the record is not deleted, and the State is WA or NC:

USE Customer DELETE TAG ALL  && So you can set KEYMATCH to first tag; && Caution: This will delete all tags in Customer.CDX INDEX ON State TAG State SET DELETED ON  SET FILTER TO State = "WA" OR State = "NC" ? KEYMATCH('WA',1,'Customer') KEYMATCHreturns a .F., no match was found. For the above example to return a .T., place the DELETED and FILTER conditions within the FOR clause of the Index expression as in this example:

USE Customer DELETE TAG ALL  && So you can set KEYMATCH to first tag; && Caution: This will delete all tags in Customer.CDX INDEX ON State FOR !DELETED AND (State = "WA" OR State = "NC") ; TAG State ?KEYMATCH('WA',1,'Customer') These changes allow KEYMATCH to recognize if the records have been marked for Deletion and meet the FILTER (STATE="WA" OR STATE="NC") setting.

STATUS
This behavior is by design.

Additional reference words: FoxDos FoxWin 2.60 2.60a FOXHELP.DBF FOXHELP.HLP KBCategory: kbprg kbprb KBSubcategory: FxprgGeneral
 * }