Microsoft KB Archive/94347

{| = PRB: &quot;Operator/Operand Type Mismatch&quot; When Indexing Fields =
 * width="100%"|

ID: Q94347

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
 * Microsoft FoxPro for Windows, versions 2.5 and 2.5a

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

INDEX ON + TO NAMELOG, where  is a character field and  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.,&quot;T&quot;,&quot;F&quot;) TO NAMELOG, where the Immediate IIF statement returns a &quot;T&quot; if the logical expression is .T. and an &quot;F&quot; if it is not. Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a errmsg err msg KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxprgGeneral
 * }