Data Validation (key press events) (1 Viewer)

ajetrumpet

Banned
Local time
Yesterday, 19:12
Joined
Jun 22, 2007
Messages
5,638
Here's a great way to validate data in a form field:
PHP:
Private Sub ControlName_KeyPress(KeyAscii As Integer)

    Select Case KeyAscii

        ' 65 To 90 and 97 To 122: These are all alpha chars, upper and lowercase
        ' 8 Backspace, 9 Tab Key, 32 Space Key

    Case 65 To 90, 97 To 122, 8, 9, 32
        ' DO NOTHING

    Case Else

        KeyAscii = 0
        MsgBox "Only Alphabetical Characters Allowed" 'optional

    End Select

End Sub
You can use the alternative of this to limit validation to numeric values only.


Microsoft Articles that are also useful

http://support.microsoft.com/kb/113547

http://support.microsoft.com/kb/210401
 
Last edited:

Users who are viewing this thread

Top Bottom