Cancel then SetFocus

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field "Final" that is checked when the user is ready to save the
record. The Before Update event has the following code:

If [SaleBal] <> 0 Then
Me.Final.Undo
MsgBox "Account is not in Balance. Payments are Due."
Else
If [ShipPL] - [ErrAmt] < 0 And [ShipPL] < -1 Then
Me.Final.Undo
MsgBox "Please complete an Error Report before finalizing this
Order."
End If
End If

Me.Cat.SetFocus

I keep getting an error when I try to SetFocus at the end which says, "You
must save the field before executing the ... SetFocus method."

I want the user to correct the problem before saving the record. What can I
do?
 
You don't say which event is running this code, but assuming that it's the
Form's BeforeUpdate event, you need to add one extra line of code just
before Me.Final.Undo line:

Cancel = True

That tells the form not to continue trying to save the record.
 
Back
Top