Hi all,
I downloaded this piece of code from the microsoft site which capitalises first letter of every name and places small caps on the rest of the name. But it seems to have one problem if the word "withe" is enterd it gets rid of the "e", i don't know why that is it seems to work in all other cases.
Here is the code:
P.S. I am calling the code in a textbox called name_input on its after update.
Any help very much appreciated, thanks in advance,
M-.
I downloaded this piece of code from the microsoft site which capitalises first letter of every name and places small caps on the rest of the name. But it seems to have one problem if the word "withe" is enterd it gets rid of the "e", i don't know why that is it seems to work in all other cases.
Here is the code:
Code:
Function Proper(x)
' Capitalize first letter of every word in a field.
' Use in an event procedure in AfterUpdate of control;
' for example, [Last Name] = Proper([Last Name]).
' Names such as O'Brien and Wilson-Smythe are properly capitalized,
' but MacDonald is changed to Macdonald, and van Buren to Van Buren.
' Note: For this function to work correctly, you must specify
' Option Compare Database in the Declarations section of this module.
'
' See Also: StrConv Function in the Microsoft Access 97 online Help.
Dim Temp$, C$, OldC$, i As Integer
If IsNull(x) Then
Exit Function
Else
Temp$ = CStr(LCase(x))
' Initialize OldC$ to a single space because first
' letter needs to be capitalized but has no preceding letter.
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
Proper = Temp$
End If
End Function
P.S. I am calling the code in a textbox called name_input on its after update.
Any help very much appreciated, thanks in advance,
M-.