Update problem

Vborg
05-30-2002, 12:32 AM
Lets say that I have one MDI form and one child form.

BEFORE:

The child form contains a button "cmdSave",ado data control, few textboxes bound to the "ado" and its data fields.

When "cmdSave" is chlicked, it executes codes that updates the ado recordset.


Code:
__________________________________________________
Private Sub cmdUpdate_Click()
On Error GoTo undoSave

If updateAdo.Recordset.EditMode = adEditAdd Then
Dim message1 As Integer
message1 = MsgBox("Are you sure you want to ADD the new record?", vbYesNo, "Add Record")
If message1 = vbYes Then
updateAdo.Recordset.Update
updateAdo.Refresh
updateAdo.Recordset.MoveLast
Call modSysUser.sysUserOpLog(refOpObj, "Update", "Complete", "Add Successful!")
End If
ElseIf updateAdo.Recordset.EditMode = adEditInProgress Then
bkmark = updateAdo.Recordset.Bookmark
Dim message As Integer
message = MsgBox("Are you sure you want to SAVE the following changes?", vbYesNo, "Save Record")
If message = vbYes Then
updateAdo.Recordset.UpdateBatch
updateAdo.Refresh
updateAdo.Recordset.Bookmark = bkmark

Call modSysUser.sysUserOpLog(refOpObj, "Update", "Complete", "Edit Successful!")
End If
End If

Exit Function
undoSave:
Dim msg As String
msg = Err.Description
Call modSysUser.sysUserOpLog(refOpObj, "Update", "Error", msg)

If updateAdo.Recordset.EditMode = adEditAdd Then
MsgBox "" & msg, , "Error"
ElseIf updateAdo.Recordset.EditMode = adEditInProgress Then
MsgBox "" & msg, , "Error"
MsgBox "Refreshing records", , "Recovery"
Call refreshTableByRef(updateAdo)
End If

End Sub
__________________________________________________



AFTER:

Everything is the same, Except I moved the "cmdSave" button to the MDI form.

While adding record:
I can succesfully execute the save method while the child forms recordset is in "adEditAdd" mode.

While editing record:
the "adEditInProgress" is only triggered if i change data in more than one fields.

Previoulsy when the "cmdSave" Button was on the child form, I only had to change data in one field and it would already trigger the "adEditInProgress" event/ set "adEditInProgress" to true.

NOTE: "adEditInProgress" and "adEditAdd" refres to the ado data control.
Also the records were changed through textboxes bould to the ado data control.

Any helo to solve this update problem will be very helpfull.

Thank you.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum