[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2002-05-04
4
Medium Priority
?
1,641 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses

649 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