TextBox Validation Against Numbers

  • Hello, i am trying to make validation so a textbox in a form can only accept only letters. At the moment however i can only seem to stop it entering numbers on its own, i cant stop it from accepting letters and numbers. here is the code so far. (please try keep the code simple as possible i have seen more diffuclt solutions but they are to difficult)


  • Re: Letter Only Form Validation


    try this in the form's code module:

    Code
    Private Sub TextBox1_Change()
        'Validation to ensure only Letters may be entered into the text box.
        If IsNumeric(Right(TextBox1, 1)) Then
            TextBox1.BackColor = &HFF&
             MsgBox ("Only letters allowed in field")
            TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
        Else
            TextBox1.BackColor = &H80000005
        End If
    End Sub


    p45cal

  • Re: TextBox Validation Against Numbers


    Thank you very much for both of your assistance. P45cal especialy your help was very...helpful :P. Dave i checked that, and the more difficult code i was reffering to before was that :P. but thats for taking your time anyways.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!