I have a text box control called txtSalary and want to check the amount and cancel it if it is greater than
I have a text box control called txtSalary and want to check the amount and cancel it if it is greater than

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
You can use the following code :
<pre>Private Sub txtSalary_BeforeUpdate(Cancel As Integer)
If Me.Text0 > 50000 Then
SendKeys "{esc}"
Cancel = True
End If
End Sub</pre>
Francois
http://www.wopr.com/S/Belgium.gif
Instead of <font face="Georgia">SendKeys "{Esc}"</font face=georgia>, one can also use
<font face="Georgia">txtSalary.Undo</font face=georgia>
This has the same effect (undoing changes to the control).