?
Solved

Edit database

Posted on 1998-09-04
4
Medium Priority
?
186 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 100 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

Independent Software Vendors: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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