[AccessD] Set Focus On Control When Validation Fails

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Sun Mar 9 12:45:00 CST 2003


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/026cc0fe/attachment.html>


More information about the AccessD mailing list