+ Reply to Thread
Results 1 to 3 of 3

validate controls

  1. #1
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136

    validate controls

    i have an excel form that i want that after the user enters data, when he tries to exit text box it validates the data for him and if it's valid the background changes to white.
    i currently have the colors changing if there is any data in the txtbox at all. i would like it to be that it needs to have two names in the field - the director's first and last name. so i want it to check the the first word is more than one letter, followed by a space, and then at least two more letters.

    i am putting the code in the txtDirector_Exit event.
    i know the changing color code, i need to code to check the data in the box.

    thanks in advance
    tkaplan

  2. #2
    Rowan
    Guest

    Re: validate controls

    Maybe like this.

    Private Sub txt_Director_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim spac As Integer
    Dim vld As Boolean
    spac = InStr(1, txt_Director.Value, " ")
    If spac < 3 Then
    vld = False
    ElseIf spac > Len(txt_Director.Value) - 2 Then
    vld = False
    Else
    vld = True
    End If
    If Not vld Then
    Me.txt_Director.BackColor = vbBlue
    End If
    End Sub

    Hope this helps
    Rowan

    tkaplan wrote:
    > i have an excel form that i want that after the user enters data, when
    > he tries to exit text box it validates the data for him and if it's
    > valid the background changes to white.
    > i currently have the colors changing if there is any data in the txtbox
    > at all. i would like it to be that it needs to have two names in the
    > field - the director's first and last name. so i want it to check the
    > the first word is more than one letter, followed by a space, and then
    > at least two more letters.
    >
    > i am putting the code in the txtDirector_Exit event.
    > i know the changing color code, i need to code to check the data in the
    > box.
    >
    > thanks in advance
    > tkaplan
    >
    >


  3. #3
    Dave Peterson
    Guest

    Re: validate controls

    You have another reply to your post in .misc

    tkaplan wrote:
    >
    > i have an excel form that i want that after the user enters data, when
    > he tries to exit text box it validates the data for him and if it's
    > valid the background changes to white.
    > i currently have the colors changing if there is any data in the txtbox
    > at all. i would like it to be that it needs to have two names in the
    > field - the director's first and last name. so i want it to check the
    > the first word is more than one letter, followed by a space, and then
    > at least two more letters.
    >
    > i am putting the code in the txtDirector_Exit event.
    > i know the changing color code, i need to code to check the data in the
    > box.
    >
    > thanks in advance
    > tkaplan
    >
    > --
    > tkaplan
    > ------------------------------------------------------------------------
    > tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
    > View this thread: http://www.excelforum.com/showthread...hreadid=469859


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1