Modify ALLCAPS memo field

S

Shadow

I have a database with a memo field that has many entries entered as allcaps.
Is there a function similar to Pcase or vb language that would permit
modifying the allcaps data in the memo field to a modified 'Proper'
capitalization with only the first letter of a sentence or bullet
capitalized? The memo field can contain several sentences or several
numbered bullets.
 
S

Shadow

Douglas J. Steele said:
Check the StrConv function.
I know about the StrConv function but do not know how to apply it to all the
words in a sentence (i.e. first word capitalized and all subsequent words
lower case). And then to stop it at the first period and restart it for the
second sentence.
 
D

Douglas J. Steele

Sorry, you're right. StrConv with the vbProperCase doesn't do what you're
looking for.

You'd have to write a function that used LCase to convert the whole thing to
lower case, then selectively use UCase to convert the first character to
upper case, as well as the first character after each period.

Something like the following untested air-code:

Function ProperCase(InputString As String) As String
Dim lngLoop As Long
Dim lngStringLength As String
Dim lngPeriod As Long
Dim strOutput As String

lngStringLength = Len(InputString)

strOutput = UCase(Left(InputString, 1)) & _
LCase(Mid(InputString, 2))

lngPeriod = InStr(strOutput, ".") + 1
Do While lngPeriod < lngStringLength
If Mid(strOutput, lngPeriod, 1) <> " " Then
Mid(strOutput, lngPeriod, 1) = UCase(Mid(strOutput, lngPeriod, 1))
lngPeriod = InStr(lngPeriod, strOutput, ".")
End If
lngPeriod = lngPeriod + 1
Loop

ProperCase = strOutput

End Function

It does have a problem in that it doesn't recognize exclamation points as
sentence ends.
 
T

Tony Toews [MVP]

Shadow said:
I have a database with a memo field that has many entries entered as allcaps.
Is there a function similar to Pcase or vb language that would permit
modifying the allcaps data in the memo field to a modified 'Proper'
capitalization with only the first letter of a sentence or bullet
capitalized? The memo field can contain several sentences or several
numbered bullets.

There's also an API call available that will switch off the Caps Lock
key which you can insert in the controls GotFocus event.
HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys
http://support.microsoft.com/?kbid=177674

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
S

Shadow

Douglas J. Steele said:
Sorry, you're right. StrConv with the vbProperCase doesn't do what you're
looking for.

You'd have to write a function that used LCase to convert the whole thing to
lower case, then selectively use UCase to convert the first character to
upper case, as well as the first character after each period.

Something like the following untested air-code:

Function ProperCase(InputString As String) As String
Dim lngLoop As Long
Dim lngStringLength As String
Dim lngPeriod As Long
Dim strOutput As String

lngStringLength = Len(InputString)

strOutput = UCase(Left(InputString, 1)) & _
LCase(Mid(InputString, 2))

lngPeriod = InStr(strOutput, ".") + 1
Do While lngPeriod < lngStringLength
If Mid(strOutput, lngPeriod, 1) <> " " Then
Mid(strOutput, lngPeriod, 1) = UCase(Mid(strOutput, lngPeriod, 1))
lngPeriod = InStr(lngPeriod, strOutput, ".")
End If
lngPeriod = lngPeriod + 1
Loop

ProperCase = strOutput

End Function

It does have a problem in that it doesn't recognize exclamation points as
sentence ends.
Thanks Douglas for your help. This saved a lot of retyping and can be used
to correct ALLCAPS data entry. There are a few problems like you mentioned
as explanation points but the conversion is infinitely better than 'StrConv'
and is acceptable for out application.
I modified 'Dim lngStringLength As String' to 'Dim lngStringLength As Long'.
The code works as long as there is a period at the end of the string of memo
comments.
Shadow
 
S

Shadow

Shadow said:
Thanks Douglas for your help. This saved a lot of retyping and can be used
to correct ALLCAPS data entry. There are a few problems like you mentioned
as explanation points but the conversion is infinitely better than 'StrConv'
and is acceptable for out application.
I modified 'Dim lngStringLength As String' to 'Dim lngStringLength As Long'.
The code works as long as there is a period at the end of the string of memo
comments.
Shadow

In order to fix the missing "." (period) problem, I added a 'Period Check'
after the Dim statements as follows:

Dim lngLoop As Long
Dim lngStringLength As Long
Dim lngPeriod As Long
Dim StrOut As String

If Right(InputString, 1 ) <> "." Then
InputString = InputString + "."
End If

lngStringLength = Len(InputString)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top