Microsoft Knowledge Base

PRB: Cannot Trap Error Number 1884 on Form

Last reviewed: May 8, 1997
Article ID: Q168191
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a

SYMPTOMS

You cannot trap duplicate key errors such as the following:

   Uniqueness of index "name" is violated (Error 1884)

when the error is caused by a user's interaction with a Grid on a form.

RESOLUTION

For a workaround that uses record buffering, place the following code in the Valid method of a TextBox of the Grid:

   IF .NOT. TABLEUPDATE()
   *Invalid Primary Key Trapped here since Error method of Grid does not.
      =AERROR(arrtemp)
      =MESSAGEBOX('Error:'+STR(arrtemp(1,1));
           +CHR(13)+arrtemp(1,2),0,'Error')
      RETURN 0
   ENDIF

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Issue the following two lines in the Command window:

          CREATE DATABASE primerr
          CREATE TABLE tblprim (fld1 c(3) PRIMARY KEY, fld2 c(2), fld3 c(3))
    

  2. Add several records to the above table.

  3. Create a new form by clicking New from the File menu.

  4. Click Form in the dialog box and click the New File button.

  5. When the form comes up, right-click on the form and select DataEnvironment from the Shortcut menu.

  6. When the DataEnvironment window comes up, right-click in the window and select Add Table from the Shortcut menu.

  7. When the Open dialog box appears, select the table created in Step 1.

  8. Drag and drop the table from the DataEnvironment to the form to make a Grid.

  9. Run the form and type in a duplicate value for a record in fld1 column and move off the record.

  10. Note Visual FoxPro presents an error message.

  11. Choose Revert and close the form.

  12. Modify the form.

  13. On the property sheet, select the combo at the top and choose the Grid.

  14. Find the Grid's Error method and add in a WAIT WINDOW command.

  15. Repeat step 9.

In version 3.0 and 3.0b, step 15 behaves the same as it did when step 9 was executed.


KBCategory: kbprb
KBSubcategory:
Additional reference words: 3.00 3.00b 5.00 5.00a
Keywords : FxprgGrid kberrmsg vfoxwin
Version : 3.0 3.0b 5.0 5.0a
Platform : WINDOWS
Issue type : kbprb


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: May 8, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.