[AccessD] Keep focus on record until valid entry

Mark Boyd MarkBoyd at McBeeAssociates.com
Mon Oct 6 10:32:15 CDT 2003


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.

 

TIA,

Mark Boyd

Sr. Systems Analyst

McBee Associates, Inc.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20031006/1402e2eb/attachment.html>


More information about the AccessD mailing list