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!

mixed case text 1

Status
Not open for further replies.

rsims

Programmer
Sep 25, 2000
12
US
I want to be able to store the data they type in a text box for first name in mixed case (ie. John). How do I acheive this when they could enter the name as john or JOHN or jOhN or whatever?

I want the mixed case 'John' to appear in all other forms and reports not what they typed.
 
Code:
Option Compare Database
Option Explicit
[red]'This is a procedure I use
'to clean up strings
'the function called is below
[/red]
Code:
Private Sub BuyerOwnerLastName_AfterUpdate()
'Strips spaces from text box control on form and
'capitalizes first letter of entry
If Not IsNull(Me.BuyerOwnerLastName.Value) Then
'This only works if there is something in the control,
'i.e., not a null
    Me.BuyerOwnerLastName.Value = _
    ProperNoSpace(Me.BuyerOwnerLastName.Value)
End If
End Sub
[red]'function below used with procedure above[/red]
Code:
Public Function ProperNoSpace(ByVal strString As String) As String
'Used with all text boxes on control except memo control
        strString = Replace(strString, " ", "", 1, -1, vbTextCompare)
'Spaces stripped
        strString = StrConv(strString, vbProperCase)
'First letter capitalized
        ProperNoSpace = strString
'Cleaned-up string replaces old string
End Function
[red]'procedure below can be used when you have a text box with a lot of text in it![/red]
Code:
Private Sub PropertyAddress_AfterUpdate()
    Me.PropertyAddress = Trim([PropertyAddress])
'trims leading and following spaces from entry into control
    Do While InStr([PropertyAddress], "  ") > 0
        Me.PropertyAddress = Replace([PropertyAddress], _
        "  ", " ", 1, -1, vbTextCompare)
    Loop
'finds and trims double spaces from address

End Sub


Judge Hopkins


There are only two rules for success: (1) Never tell everything you know.
 
GingerR is usually correct about most things.

However, if you search the forum for proper case, you will get around 7 million hits.

Try, instead, searching for "vbProperCase" (all one word, without the quote marks).

Judge Hopkins


There are only two rules for success: (1) Never tell everything you know.
 
i just searched only this (forms) forum. got three hits i think. the first one had the whole explanation that you/we end up giving anyway.

in any case, at least it's a hint for people to check around first, right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top