Solved

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

Posted on 2002-05-04
4
1,600 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 100 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

Technology Partners: 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 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…
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…
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…
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…

730 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