Solved

Edit database

Posted on 1998-09-04
4
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

690 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