juz a little question on input mask. Can i use input mask to force the first letter of a word to become a capital letter when a user enters in a txt box??
My answer will have nothing to do with input mask. But a neat utility called ProperCase which will uppercase the first letter of each word in string. It is found in the FUNCDEMO.ZIP file at
Maboo, that's the problem with setting an INPUT MASK - it presumes an exact character input. If you don't know how long the input strings will be, you'll probably need to use a special function like STRCONV() or an 3rd party solution such as GeekInGlasses suggested.
You can use STRCONV on the BEFORE_UPDATE event of a control to convert the input:
MyField = strConv(MyField, vbProperCase)
Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
There must be a better way than this!? Can't you just examine the first letter of a string and if it isn't a capital convert it to the capital equivalent?
You don't need to know the exact number of characters - just use:
>L<??????????????????? for a 20 character field. The "?" is optional, so you don't have to enter that many characters. If you enter "test", it will display "Test".
This is the easiest way to do this.
Of course, the other option is to let them put data in in either upper or lower case, and just convert it when you display it in a form or report - but that's more work.
re GDGarth's post - yeah, this seems to work fine in A2K - but I swear it didn't work this way in A97..hmmm..
It is obviously the easiest way to do it. Which is what I would have used...had it worked in A97...I only have A2K loaded on the beast now, so I can't go back and test (or should I say Test) it...
Good point.
Jim Me? Ambivalent? Well, yes and no....
Another free Access forum:
This function I wrote a few years ago converts all characters in a string to UCase, but ignores characters already in UCase, so can handle say:
Function RealProper(varString As Variant) As Variant
Dim i As Integer
Dim strString As String
Dim strCurrChar As String, strPrevChar As String
If IsNull(varString) Then
Exit Function
End If
strString = CStr(varString)
For i = 1 To Len(strString)
strCurrChar = Mid$(strString, i, 1)
Select Case strPrevChar
Case "A" To "Z" 'ignore characters that are already UCase
Case "a" To "z"
Mid(strString, i, 1) = LCase(strCurrChar)
Case Else
Mid(strString, i, 1) = UCase(strCurrChar)
End Select
strPrevChar = strCurrChar
Next i
RealProper = CVar(strString)
End Function
msgbox RealProper("the AA is better than the RAC says mr mcDonald!)
This would return: "The AA Is Better Than The RAC Says Mr McDonald!"
vbProperCase would return "The Aa Is Better Than The Rac Says Mr Mcdonald!"
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.