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
- 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.
- Set the following properties for these controls:
Text1
DataSource Data1
DataField ISBN
Data1
DatabaseName Biblio.mdb
Recordsource Titles
- Run the program by clicking Start on the Run menu.
- 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.
- Close Form2 by double-clicking its control box.
- 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.
- Close Form2 by double-clicking its control box. Now you will get the
error message:
Can't have duplicate key; index changes were unsuccessful.
|