I need to be able to capitalize the first letter of each word. I can seem to find anything that works. Does anyone out there have the answer? I sure would appreciate it. <p>Lanie<br><a href=mailto:etroidl@conaxfl.com>etroidl@conaxfl.com</a><br><a href= > </a><br>
You might want to use Len function to determin the length of the string, then use Mid function to check when the next character appears after space and then Left(UCase(MyString),1). <br>
<br>
I'll show you something I've done just to give you ageneral overview, but you'll have to modify the code to suit your needs:<br>
<br>
Private Sub cmbTest_Click()<br>
Dim I, L As Integer<br>
Dim FindFirstName, FindLastName<br>
Dim LName As String<br>
Dim FName As String<br>
<br>
lblIndex.Caption = "Index: " + Str(cmbTest.ListIndex)<br>
L = Len(cmbTest.Text)<br>
For I = 1 To L<br>
FindLastName = Mid(cmbTest.Text, 1, I)<br>
If Right(FindLastName, 1) = "," Then<br>
GoTo FindFirst<br>
Else<br>
LName = FindLastName<br>
End If<br>
Next I<br>
<br>
FindFirst:<br>
I = Len(LName) + 2<br>
L = Len(cmbTest.Text)<br>
<br>
FindFirstName = Mid(cmbTest.Text, I, L)<br>
FName = FindFirstName<br>
<br>
lblLastname.Caption = "Lastname: " + Trim(LName)<br>
lblFirstname.Caption = "Firstname: " + Trim(FName)<br>
<br>
<br>
<br>
End Sub<br>
<br>
I am sure that there is an easier way, so keep looking and trying.
If each name is a separate field this is a slick one liner.<br>
You can call this from a query or form or report<br>
<br>
Public Function ConvertUpper(Value)<br>
<br>
ConvertUpper = UCase(Left(Value, 1)) & Right(Value, Len(Value) - 1)<br>
<br>
End Function<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
From Access Help:<br>
<br>
PROPER<br>
Capitalizes the first letter in each word of a text string and converts all other letters to lowercase letters.<br>
<br>
Syntax<br>
<br>
PROPER(text)<br>
<br>
Text is text enclosed in quotation marks, a formula that returns text, or a reference to a cell that contains text to partially capitalize.<br>
<br>
Proper???<br>
<br>
Which version of Access is that, It's not in '97?<br>
If I type it in and Press F1 on it I get "Keyword not found". <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
Try StrConv - Hard code the conversion number (don't use vbProperCase for example)<br>
<br>
StrConv(string, conversion)<br>
<br>
The StrConv function syntax has these named arguments:<br>
<br>
string = The string expression to be converted.<br>
conversion = Value specifying the type of conversion to perform.<br>
<br>
The conversion argument settings are:<br>
<br>
Constant Value Description<br>
<br>
vbUpperCase 1 All uppercase characters.<br>
vbLowerCase 2 All lowercase characters.<br>
vbProperCase 3 Converts the first letter of every word in string to uppercase.<br>
<p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
Proper is available in Access 2000. It looked so familiar I had forgotton I used to have to use StrConv(string, vbProper) in 97. <br>
<br>
JimConrad, did you have trouble when you used the constant instead of the 3? I don't remember that, but it was awhile ago.
In some places (like in a query), you need to use the literal "3". If you are using VBA code, you can use the constant "vbProper". <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
Lanie,<br>
<br>
I wrote the following function for names. It has worked well so far.<br>
<br>
Mike<br>
<br>
Public Function MixCase(ByVal strTextIn As String) As String<br>
'This function returns a string where<br>
'the first letter of each word is upper case and<br>
'the rest of the letters of each word are lower case.<br>
'<br>
'It also handles Mc names, hyphens, and apostrophies.<br>
'<br>
'Thus when strTextIn = "BEE BOP bO LULA",<br>
'MixedCase = "Bee Bop Bo Lula"<br>
'Author: Mike Angelastro<br>
'Date: 3-20-2000<br>
<br>
Dim strTemp As String<br>
Dim strChar As String<br>
Dim intVowels As Integer<br>
Dim n As Long<br>
<br>
'Exit if input is null<br>
If IsNull(strTextIn) Then<br>
MixCase = " "<br>
Exit Function<br>
End If<br>
'Look for absence of vowels, in which case capitalize all letters.<br>
intVowels = InStr(1, strTextIn, "a", 1) Or InStr(1, strTextIn, "e", 1) Or InStr(1, strTextIn, "i", 1) Or InStr(1, strTextIn, "o", 1) Or InStr(1, strTextIn, "u", 1) Or InStr(1, strTextIn, "y", 1)<br>
If intVowels = 0 Then<br>
MixCase = UCase(strTextIn)<br>
Exit Function<br>
End If<br>
'Build output string.<br>
MixCase = UCase(Left(strTextIn, 1)) 'Capitalize the first letter of the string.<br>
For n = 2 To Len(strTextIn)<br>
strTemp = Right(strTextIn, Len(strTextIn) - n + 1) 'Derive the balance of the string in.<br>
strChar = Right(MixCase, 1) 'Derive the last character of the balance of string in.<br>
Select Case strChar<br>
Case "c"<br>
If Right(MixCase, 2) = "mc" Or Right(MixCase, 3) = "mac" Then 'Look for "Mc" or "Mac" names.<br>
MixCase = MixCase & UCase(Left(strTemp, 1)) 'Convert character to upper case.<br>
Else<br>
MixCase = MixCase & LCase(Left(strTemp, 1)) 'Convert character to lower case.<br>
End If<br>
Case ".", " ", "-", "'" 'Space, hyphen, period, or apostrophy.<br>
MixCase = MixCase & UCase(Left(strTemp, 1)) 'Convert character to upper case.<br>
Case Else<br>
If strChar <> "c" Then MixCase = MixCase & LCase(Left(strTemp, 1)) 'Convert character to lower case.<br>
End Select<br>
Next<br>
<br>
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.