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

ID: Q147780

2.60 2.60a WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

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
Keywords          : FxprgGeneral kbbuglist kbfixlist
Version           : 2.60 2.60a
Platform          : WINDOWS

Last Reviewed: March 8, 1996