ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   validate controls (https://www.excelbanter.com/excel-programming/340826-validate-controls.html)

tkaplan[_5_]

validate controls
 

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

thanks in advance
tkapla

--
tkapla
-----------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...fo&userid=2298
View this thread: http://www.excelforum.com/showthread.php?threadid=46985


Rowan[_9_]

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



Dave Peterson

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


All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com