[AccessD] Keep focus on record until valid entry

Gustav Brock gustav at cactus.dk
Mon Oct 6 10:54:32 CDT 2003


Hi Mark

You should be able to set Cancel = True in the Before Update event.
If not for the control, you can do for the form.

/gustav


> This seems like a simple task.

> I have a continuous form with the following fields:
> [AcctNum],[Charges],[Payments],[Balance].

> I do not want the user to be able to move off of the record if [Balance]
> <> [Charges]-[Payments].

> I put the following code in the AfterUpdate event of the [Balance]
> field:

> If Me.Balance <> (Nz(Me.Charges) - Nz(Me.Payments)) Then

>    MsgBox "Current Balance does not equal Total Charges minus
> Payments.", vbCritical, "Error"

>    Me.Balance.SetFocus

> End If

> I receive the message box, but the focus automatically moves to the next
> record.

> How can I keep the focus on the current record?  I tried moving the code
> to the BeforeUpdate event, but the same results.



More information about the AccessD mailing list