Solved

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

Posted on 2002-05-04
4
1,567 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
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ramani_gr
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now