Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

any vbs to turn first letters of words in a field to uppercase? 1

Status
Not open for further replies.

barny2006

MIS
Mar 30, 2006
521
US
hi folks,
is there an app/vbs/vba that can turn first letters of words in a field to uppercase and the rest lf the letters to lowercase?
 
Use an input mask: >L???????????????????????????
the > symbol means switch that character to uppercase, the L stands for letter, and the ? stands for any character.

Tom

Live once die twice; live twice die once.
 
cool,
but i think that's for the whole field. i want each word in the field to have uppercase for the first char.
 
copied from:


Code:
data = " 21"",""BOB D."",""StePHhens"",""SA052"",""CALL REAL ESTATE""," _
& """CALL01"",""(804)411-2222"" "

With New RegExp
.Global = True
.IgnoreCase = True

.Pattern = "\b(\w)(\w*?)\b"
WScript.echo .Replace(data, GetRef("ProperCase"))

.Pattern = "\b([a-z])([a-z]*?)\b"
WScript.echo .Replace(data, GetRef("ProperCase"))
End With

Function ProperCase(match, submatch1, submatch2, index, source)
ProperCase = UCase(submatch1) & LCase(submatch2)
End Function


Hope this helps.

[vampire][bat]
 
Do you want to force capitlization on entry or after update?
If after update, try this:

Code:
Private Sub [!]MyText[/!]_AfterUpdate()
Dim strMyText As String

strMyText = Me.[!]MyText[/!].Value
strMyText = StrConv(strMyText, vbProperCase)
Me.[!]MyText[/!].Value = strMyText

End Sub

You will need to change the items in red to the actual name of your text box, of course. [smile]
Hope this helps...
Tom

Live once die twice; live twice die once.
 
this is a batch process that process the whole table to be ready for printing on letters (mail/merge).

thank you folks. it works great with any string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top