ProperCase Function/Routine 
Author Message
 ProperCase Function/Routine

Anyone willing to share their ProperCase function code with me?



Sat, 15 Apr 2000 03:00:00 GMT  
 ProperCase Function/Routine

> Anyone willing to share their ProperCase function code with me?

Keith, if you are using Access 97 and want something simple use the StrConv

If you are using an earlier Access or if you want some more control the
function below works well. I got it from Microsoft's neatcode.mdb which was
made available with Access 2.0 a few years ago. I have changed one line
(the original line is commented) so that the string is not converted to
lower case before capitalisation. This means that the user can force upper
case letters within a word in cases such as MacDonald.

HTH, Mark

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]).
'  Note: For this function to work correctly, you must specify
'  Option Compare Database in the Declarations section of this module.
Dim Temp$, C$, OldC$, I As Integer
  If IsNull(x) Then
    Exit Function
  ElseIf Len(x) = 0 Then
    Exit Function

' This is the line I have changed
'    Temp$ = CStr(LCase(x))
    Temp$ = CStr(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

Thu, 20 Apr 2000 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Propercase

2. Prob#2, ProperCase issue

3. How to change a string to ProperCase

4. changing UPPERCASE to ProperCase

5. Geneology type query/routine/function

6. Feedback for correct use of a sub/function routines

7. Mouse routines/functions in QB4.5?

8. Newbie-Question: Activating VB-routine via function key

9. IMPORTANT: SHELL functions (Disk routines/FileSystem/ShellOperations/LNKFiles etc)

10. Function, routine or sub

11. Routine Functions

12. calling a Javascript function from and asp Sub Routine


Powered by phpBB® Forum Software