Microsoft KB Archive/170148

= FIX: Cannot Trap Error Number 1884 on Form =

Article ID: 170148

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q170148



SYMPTOMS
You cannot trap duplicate key errors such as the following when the error is caused by a user's interaction with a grid on a form:

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



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 has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This has been corrected in Visual FoxPro 6.0.



Steps to Reproduce Behavior
  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))  Add several records to the above table. Create a new form by selecting New from the File menu. Select Form in the dialog box and click the New File button. When the form appears, right-click on the form to invoke the shortcut menu and click DataEnvironment. When the DataEnvironment window comes up, right-click in the window to invoke the shortcut menu and click Add Table.</li> When the Open dialog box appears, select the table created in Step 1.</li> Drag and drop the table from the DataEnvironment to the form to make a grid.</li> Run the form and type in a duplicate value for a record in fld1 column and move off the record. Note that Visual FoxPro presents an error message.</li> Click Revert and close the form.</li> Modify the form.</li> On the property sheet, select Grid from the drop down box at the top.</li> Find the grid's Error method and add in a WAIT WINDOW command.</li> Repeat step 9.</li></ol>

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

Keywords: kberrmsg kbbug kbfix kbvfp600fix kbprb KB170148

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.