subform - update from combobox on mainform

  • Thread starter Thread starter Michel Peeters
  • Start date Start date
M

Michel Peeters

I have a combo box on the mainform.
In the after-update event from the combo I wrote : "Me.recalc".
This causes the subform to "update".
This works fine but when I get in conflict with the validation rules of the
mainform:

Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.txtDatum) Then
MsgBox "...."
DoCmd.CancelEvent
End If

I receive Error 2001: you cancelled the previous operation.

What should I change?
Or is there a better way to update the subform?

tks
Michel P.
 
One quick answer is to put an error trap in the code that runs the
recalculate operation:

Private Sub combobox_AfterUpdate()
On Error Resume Next
Me.Recalc
If Err.Number = 2501 Then
' ignore this error, the form's before update event
' cancelled the operation
ElseIf Err.Number <> 0 Then
' some other error has happened
MsgBox "An Error has occurred."
End If
End Sub
 
Back
Top