?
Solved

How to fix this error: OIP-04119: Data has been modified

Posted on 2002-05-04
4
Medium Priority
?
1,621 Views
Last Modified: 2007-11-27
I have a VB6.0 application with editable DBGrid and oracle
data control and some textBox. The DBGrid and textBoxs are bound to the ORADC.

I have three buttons, new, delete and save.
When i click the New button, i fill the textboxs. Then i click Save Button to save the new record.

The problem is - after i click Save button, if i want to make change to this record and click Save button again(or if i want to delete this new record), i always get this message

Run-time error '440': OIP-04119: Data has been modified.

I cannot fix this bugs and don't know what cause it, and i cannot get any information from the website. So i have to ask some experts for help.

Please help me. Thank you


Private Sub SSCommandNew_Click()
   If oradcItem.EditMode = dbEditAdd Then
      MsgBox "You have already Added a record without Saving.", vbInformation
      Exit Sub
   End If
   oradcItem.Recordset.AddNew
   DBGrid1.AllowAddNew = True
End Sub

Private Sub SSCommandDelete_Click()
   Dim iRet As Integer
 
   If oradcItem.EditMode = dbEditAdd Then
    MsgBox "You can't Delete an Unsaved record.", vbInformation
    Exit Sub
   End If
 
   With oradcItem.Recordset
    If .RecordCount = 0 Then Exit Sub
    iRet = MsgBox("Do you want to Delete this record?", vbYesNo, vbQuestion)
    If iRet <> 6 Then Exit Sub
    .Delete
    .Refresh
   End With
   
End Sub

Private Sub SSCommandUpdate_Click()
   On Error GoTo Errhandler
   If oradcItem.EditMode = dbEditNone Then
      oradcItem.Recordset.Edit
   End If
   oradcItem.Recordset.Update
   DBGrid1.AllowAddNew = False
   
Errhandler:
   If Err.Number > 0 Then
      MsgBox Err.Source & " " & Err.Description, vbCritical, "Error"
   End If
   
End Sub

0
Comment
Question by:huhu
[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 1

Expert Comment

by:ramani_gr
ID: 6991052
Could you rewrite this Sub and check.

Private Sub SSCommandUpdate_Click()
  On Error GoTo Errhandler
  If Not DBGrid1.DataChanged Then
     oradcItem.Recordset.Edit
     DBGrid1.DataChanged = True
  End If
  oradcItem.Recordset.Update
  DBGrid1.AllowAddNew = False
 
Errhandler:
  If Err.Number > 0 Then
     MsgBox Err.Source & " " & Err.Description, vbCritical, "Error"
  End If
End Sub

Good luck.
0
 

Author Comment

by:huhu
ID: 6991270
Hello, Ramani,

   It doesn't work. If i do so, the new record cannot be saved since the recordset is always set as Edit mode.
0
 

Accepted Solution

by:
huer earned 400 total points
ID: 6991892
Hello,

OO4O does have some bugs in ver 7.2.2 and older with update problems. Try and use the dirty_write method during the CreateDynaset method. This will allow you to rewrite over previously updated info. It should look something
like the following;

Set yourOraDynaset = yourOraDatabase.CreateDynaset (strSQL, ORADYN_DIRTY_WRITE)


If you use ORADC, set the DirtyWrite property to TRUE

Add  oradcItem.DirtyWrite = True to your code and it will works fine.



Private Sub mnuitmSave_Click()
   On Error GoTo Errhandler
 
   oradcItem.DirtyWrite = True
   If oradcItem.EditMode = dbEditNone Then
      oradcItem.Recordset.Edit
   End If
   
   oradcItem.Recordset.Update
   DBGrid1.AllowAddNew = False
 
Errhandler:
   If Err.Number > 0 Then
      MsgBox Err.Source & " " & Err.Description, vbCritical, "Error"
   End If
   
End Sub
0
 

Author Comment

by:huhu
ID: 6992256
Thanks
0

Featured Post

Industry Leaders: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Suggested Courses

762 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