Solved

Edit database

Posted on 1998-09-04
4
176 Views
Last Modified: 2010-04-30
What's the best way to edit in a database?
I have a database, and I want to edit an item. I have tryed this:

Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String)
    rsTable.MoveFirst
    rsTable.Seek "=", TreeView1.SelectedItem
    rsTable.Edit
    rsTable!Item = NewString
    rsTable.Update
End Sub

but I get a "Run-time error: 3022" what am I doing wrong?
0
Comment
Question by:Olli083097
  • 2
4 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1433089
What is an error 3022?
0
 

Author Comment

by:Olli083097
ID: 1433090
Run-time error '3022':

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redifine the index to permit duplicate entries and try again.
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 50 total points
ID: 1433091
Olli, you read the error... That is your help.
If you want to monitor for the error (which is the only thing you can do here except for perhaps changing your file's key) then I would first check the value against the file to see if the duplicate key already exists; if it does then inform the user of this and don't attempt to add duplicate keys.  If not then you may change the key... All that has occurred here is that you have written code that is attempting to violate (or allows the user to enter a value that violates) the integrity of the database.  Sorry, either change the database or code according to the database restraints.
0
 

Author Comment

by:Olli083097
ID: 1433092
Youre right! Stupid of me... :-)
Thanx!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question