Andy Lacey
andy at minstersystems.co.uk
Sun Mar 9 13:17:00 CST 2003
Rocky
Have you tried in BeforeUpdate? then you don't need to set focus, just
set Cancel to True and it'll stay there.
Andy Lacey
http://www.minstersystems.co.uk <http://www.minstersystems.co.uk/>
-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com] On Behalf Of Rocky Smolin -
Beach Access Software
Sent: 09 March 2003 18:45
To: AccessD at databaseadvisors.com
Subject: [AccessD] Set Focus On Control When Validation Fails
Dear List
I have a couple of simple validation tests:
If Not IsNumeric(Nz(txtStartingRoomNumber)) Then
MsgBox "Starting Room Number Must Be Numeric.", vbExclamation
txtStartingRoomNumber.SetFocus
Exit Sub
End If
If Val(Nz(txtStartingRoomNumber)) > 9999999 Then
MsgBox "Starting Room Number Must Be Less Than 7 Digits.",
vbExclamation
txtStartingRoomNumber.SetFocus
Exit Sub
End If
in the AfterUpdate event of txtStartingRoomNumber. But the SetFocus
does not work. The focus ends up being set on the next control in the
tab sequence. I tried the tests in the Lost Focus event with the same
result.
I know there must be a simple way to return the focus to the control but
I can't see it. (Maybe I shouldn't work on Sunday but the kids are in
Sunday school and it's quiet.) :)
MTIA,
Rocky Smolin
Beach Access Software
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030309/86238579/attachment-0001.html>