FIX: LOOKUP() Function Returns "Data Type Mismatch"

Last reviewed: March 6, 1996
Article ID: Q147780
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.6 and 2.6a

SYMPTOMS

When you use the LOOKUP function to search for information, the error "Data Type Mismatch" will occur if there is a filter set on the table and an index does not exist on the searched field. The filter can be set to any field, but if an index has not been created for the field that the LOOKUP function is searching, the error will occur.

WORKAROUND

Index the field that is to be searched before using the LOOKUP function.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 3.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

Place the following code into a program:

   CREATE TABLE test (city c(10))
   INSERT INTO test (city) VALUES ("NEW YORK")
   INSERT INTO test (city) VALUES ("SEATTLE")
   INSERT INTO test (city) VALUES ("DENVER")
   INSERT INTO test (city) VALUES ("CHARLOTTE")

   SET FILTER TO city = "NEW YORK"

   ? LOOKUP(Test.city, "NEW YORK", Test.city)

Run the program, and note that the error "Data Type Mismatch" occurs. Add the following line of code before the LOOKUP function:

   INDEX ON city TAG city

Now the LOOKUP function will work correctly. The index on the search field will also help find records faster when you use the LOOKUP() function.

Also please note that if there is no index, the LOOKUP() function will locate deleted records even though SET DELETED is ON. For more information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q122511
   TITLE     : BUG: LOOKUP() Locates Deleted Records


Additional reference words: 2.60 2.60a FoxWin buglist2.60 buglist2.60a
fixlist3.00
KBCategory: kbprg kbbuglist kbfixlist
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 6, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.