My form is based on a DAO.Recordset, a dynaset based on a table & view on SQL Server with the recordset.Restartable = True. The join is done in the queryDef of the recordset of the form where the view is a calculation.
Two important controls determine the outcome which sets the opposing ctrl null on entering data:
Which then fires the beforeUpdate event of the form which does data-validation on numerical limits... If data-validation is successful the BeforeUpdate event I don't cancel the BeforeUpdate event. BUT sometimes the current record is lost in the BeforeUpdate event. Presumably with the bookmark being lost. At this stage the recordset contains the correct Me.Recordset.Recordcount but it is set to Me.Recordset.BOF & Me.Recordset.EOF causing 'No current record' error. If I try to comabit this within the BeforeUpdate event:
I get the 'runtime error 3426 The action was cancelled by an associated object'. What is a sound coding pattern to avoid this?
EDIT - It's all avoidable if I don't requery the form but I want the user to be able to see the changes in real-time, whilst staying on the current record.
Two important controls determine the outcome which sets the opposing ctrl null on entering data:
Code:
Private Sub txtCtrl1_AfterUpdate()
If Not txtCtrl1 Then
Me.txtCtrl2 = Null
Me.Recordset.Requery
End If
Private Sub txtCtrl2_AfterUpdate()
If Not txtResEquivalentTo Then
Me.txtCtrl1 = Null
Me.Recordset.Requery
End If
Code:
If Me.Recordset.RecordCount > 1 And Me.Recordset.BOF Or Me.Recordset.EOF Then
Me.Recordset.FindFirst "FieldName = " & Me.txtRecordID
End If
EDIT - It's all avoidable if I don't requery the form but I want the user to be able to see the changes in real-time, whilst staying on the current record.
Last edited: