Solved

Edit database

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

790 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