Private Sub cmdUpdate_Click()
' Save contents of bound controls ' to underlying recordset datCtl.Recordset.Update End Sub Private Sub cmdUpdate_Click() If datCtl.Recordset.EditMode = dbEditNone Then datCtl.Recordset.Edit End If datCtl.Recordset.Update End Sub The following code, which works fine under VB3, may generate runtime Error 3426 The action was cancelled by an associated object in the 16-bit version of VB4 (the code also errors out under VB4/32, but with the more-accurate Error 3020 Update or CancelUpdate without AddNew or Edit): The problem seems to be caused by the fact that, unlike VB3, VB4 does not perform an implicit Edit method whenever the Data Control moves to a new record. The solution is to check the recordset As EditMode and perform an explicit Edit method if necessary: Another workaround is to replace the Update method with the Data Control As UpdateRecord method, which is functionally equivalent to performing an Edit followed by an Update. The drawback is that UpdateRecord does not fire a Validate event, so you shouldn't use it if you rely on that event to perform data validation. |