Solved

Edit database

Posted on 1998-09-04
4
145 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now