Hi all,
I have a code which checks in a textbox called: Name_input if it is null if so it exits procedure if entry has been made runs it. The procedure puts the entry into proper case.
I want the procdure to have an added condition to the isnull one, i want it to check if entry is already in proper case format is well, if it is then exit sub.
so something like:
if isNull(textbox) and textbox = Block 2 (below) then
exit sub
else
run Block 1 (below)
Here is the code i have so far:
Any help appreciated, thanks in advance,
M-.
I have a code which checks in a textbox called: Name_input if it is null if so it exits procedure if entry has been made runs it. The procedure puts the entry into proper case.
I want the procdure to have an added condition to the isnull one, i want it to check if entry is already in proper case format is well, if it is then exit sub.
so something like:
if isNull(textbox) and textbox = Block 2 (below) then
exit sub
else
run Block 1 (below)
Here is the code i have so far:
Code:
Private Sub Name_input_Exit(cancel As Integer)
Dim Temp$, C$, OldC$, i As Integer
Dim prompt
[COLOR=Green]'condition for code to run at present[/color Green]
If IsNull(Me.Name_input) Then
Exit Sub
Else
[COLOR=blue]'Block1
'----I want to be able to carry this block out if textbox entry is not null and <> block 2 below------[/color blue]
prompt = MsgBox("Do you want the Name in proper case", vbYesNo, "Proper Case")
If prompt = vbYes Then
[COLOR=red]'Block2
'--------------------I want to compare this region (Proper case) with textbox entry-----------[/color red]
Temp$ = CStr(LCase(Me.Name_input))
[COLOR=Green] ' Initialize OldC$ to a single space because first
' letter needs to be capitalized but has no preceding letter.[/color Green]
OldC$ = " "
For i = 1 To Len(Temp$)
C$ = Mid$(Temp$, i, 1)
If C$ >= "a" And C$ <= "z" And (OldC$ < "a" Or OldC$ > "z") Then
Mid$(Temp$, i, 1) = UCase$(C$)
End If
OldC$ = C$
Next i
[COLOR=red]'---------------------------------Block2 End--------------------------------------------------[/color red]
[COLOR=Green] 'set name input textbox to proper case[/color Green]
Me.Name_input = Temp$
Else
Exit Sub
End If
[COLOR=blue]'--------------------------------Block1 End-----------------------------------------------------[/color blue]
End If
End Sub
Any help appreciated, thanks in advance,
M-.