Link to home
Start Free TrialLog in
Avatar of huhu
huhu

asked on

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

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

Avatar of ramani_gr
ramani_gr

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.
Avatar of huhu

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of huer
huer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of huhu

ASKER

Thanks