Prevent New Record or form from advancing unless....

R

Randy

I need a way to prevent my form from either moving back or forward through
records or inserting a new record unless the following code has been met.
The [Debit] must agree with Accountsubform.Form!SumFee before the user can
tab through to the next field. This works fine, but if the [Debit] does not
agree with Accountsubform.Form!SumFee and the user for whatever reason
decides to either insert a new record or moves back to a previous record
prior to tabbing through to Accountsubform.Form!SumFee, the code is bypassed
and incorrect data is entered into the table. How can I prevent
this?...Thanks...Randy

Private Sub TotalFee_BeforeUpdate(Cancel As Integer)
If Accountsubform.Form!SumFee <> [Debit] Then
If MsgBox("Total Fee's Do Not Agree. Review Fee's and make
necessary correction", vbYes + vbDefaultButton2) <> vbYes Then
Cancel = True
Me.Form![Debit].SetFocus
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top