PRB: "Operator/Operand Type Mismatch" When Indexing Fields

ID: Q94347

The information in this article applies to:

SYMPTOMS

The INDEX ON command returns an "Operator/operand type mismatch" error message when concatenating a character field with a logical field as in the following example

   INDEX ON <NAME>+<LOG> TO NAMELOG,

where <NAME> is a character field and <LOG> is a logical field.

CAUSE

These fields are not of the same data type; therefore, a conversion must be performed to make them compatible.

RESOLUTION

Because there is no function that translates a character string into a logical string or vice versa, the following command is recommended

   INDEX ON NAME+IIF(LOG=.T.,"T","F") TO NAMELOG,

where the Immediate IIF statement returns a "T" if the logical expression is .T. and an "F" if it is not.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a errmsg err msg KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995