PRB: "Division by 0" with SET FILTER Condition on BROWSE

ID: Q117707

The information in this article applies to:

  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SYMPTOMS

Using the DOWN ARROW or the PAGE DOWN key to move the record pointer to the end of the database during a BROWSE generates a "Division by 0" error message.

For example, if you type the following commands in the Command window

   USE <FoxPro_directory>\tutorial\salesman
   SET FILTER TO MOD(10000,ytdsales) = 10000
   BROWSE

and then press the PAGE DOWN key to get to the bottom of the listing, you will receive the following error message:

   Division by zero

NOTE: When the error occurs, FoxPro for MS-DOS and FoxPro for Macintosh inform you that the filter has been cleared, whereas FoxPro for Windows does not.

CAUSE

Under a normal BROWSE condition, one with no filter set, the end-of-file (EOF) marker is identified and the pointer is automatically moved back to the last record in the list. In this situation, nothing is requested to be evaluated, nothing is evaluated, and no error condition (of any kind) should be present.

However, in the example above, the filter is evaluating the EOF marker. The value of YTDSALES at that point is equivalent to zero (0). Therefore, division by zero takes place and the error message is displayed.

RESOLUTION

Change the filter condition to include an IIF() function. For example:

   SET FILTER TO MOD(10000,IIF(ytdsales=0,1,ytdsales)) = 10000

Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.50c 2.60 errmsg err msg KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxprgBrowse


Last Reviewed: June 27, 1995
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.