BUG: Errors with Duplicate Keys and Modal/Modeless Forms

Last reviewed: September 26, 1995
Article ID: Q137036
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0

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.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic 3.0. Form1 is created by default.

  2. Add a second form to the project by clicking New Form on the Visual Basic File menu. Form2 is created by default.

  3. Place two command buttons (Command1 and Command2) on the Form1.

  4. Set the Caption property of Command1 to Modeless and set the Caption property of Command2 to Modal.

  5. 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

  6. Place a text box (Text1) and a data control (Data1) on Form2.

  7. Set the following properties for these controls:

    Text1

          DataSource     Data1
          DataField      ISBN
    
       Data1
          DatabaseName   Biblio.mdb
          Recordsource   Titles
    
    

  8. Run the program by clicking Start on the Run menu.

  9. 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.

  10. Close Form2 by double-clicking its control box.

  11. 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.
    

  12. Close Form2 by double-clicking its control box. Now you will get the

        error message:
    

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


Additional reference words: 3.00
KBCategory: kbprg kbbuglist kberrmsg
KBSubcategory: PrgCtrlsStd


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: September 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.