Mark Boyd
MarkBoyd at McBeeAssociates.com
Mon Oct 6 11:00:13 CDT 2003
Perfect! Thanks Gustav. Mark -----Original Message----- From: Gustav Brock [mailto:gustav at cactus.dk] Sent: Monday, October 06, 2003 11:55 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Keep focus on record until valid entry 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. _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com