Microsoft KB Archive/137036

= BUG: Errors with Duplicate Keys and Modal/Modeless Forms =

Article ID: 137036

Article Last Modified on 10/30/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q137036



SYMPTOMS
When you enter a duplicate value for a key field, you will notice different behavior depending on whether the form is shown as modal or modeless. When you have a modeless form and a duplicate value for a key field, the error "Can't have duplicate key; index changes were unsuccessful" appears as you try to move to the next record. When you have a modal form, this error appears as you try to unload the form. In both cases, Visual Basic does not save the duplicate data.



STATUS
Microsoft has confirmed this to be a problem in Visual Basic version 3.0 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Problem
 Start a new project in Visual Basic 3.0. Form1 is created by default. Add a second form to the project by clicking New Form on the Visual Basic File menu. Form2 is created by default. Place two command buttons (Command1 and Command2) on the Form1. Set the Caption property of Command1 to Modeless and set the Caption property of Command2 to Modal.  Place the following code in the Click event procedure for Command1: form2.Show Then place the following code in the Click event procedure for Command2: form2.Show 1  Place a text box (Text1) and a data control (Data1) on Form2.</li>  Set the following properties for these controls: Text1 DataSource    Data1 DataField     ISBN Data1 DatabaseName  Biblio.mdb Recordsource  Titles </li> Run the program by clicking Start on the Run menu.</li> Click the Modeless button. This will show Form2 with the first record of the database. Select the text in the text box, and copy it by pressing CTRL+INS. Move to the next record, and select the new text in the text box. Paste the text from the previous record into the text box by pressing SHIFT+INS. On trying to move to a new record, you will receive this error message.

Can't have duplicate key; index changes were unsuccessful.

</li> Close Form2 by double-clicking its control box.</li> Click the Modal button on Form1. Form2 will appear again with the first record of the database. Select the text in the text box, and copy it by pressing CTRL-INS. Move to the next record, and select the new text in the text box. Paste the text from the previous record into the text box by pressing SHIFT-INS. On trying to move to a new record, you will not receive an error message.</li> Close Form2 by double-clicking its control box. Now you will get the error message:

Can't have duplicate key; index changes were unsuccessful.

</li></ol>

Additional query words: 3.00

Keywords: kbbug KB137036

-

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

© Microsoft Corporation. All rights reserved.