Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Public Function CapSentences(ByVal Txt As String) As String
Dim idx As Long, idxStr As Long, Max As Long, Ltr As String
DoCmd.Hourglass True
idx = 1
Max = Len(Txt)
If Txt <> "" Then
Do
Ltr = UCase(Mid(Txt, idx, 1))
If Ltr >= "A" And Ltr <= "Z" Then
Mid(Txt, idx, 1) = Ltr
Exit Do
Else
idx = idx + 1
End If
Loop Until idx >= Max
idx = 1
Do
'idxStr = InStr(idx, Txt, ".")
idxStr = NextIdx(Txt, idx, Max)
If idxStr Then
Do
Ltr = UCase(Mid(Txt, idxStr, 1))
If Ltr >= "A" And Ltr <= "Z" Then
Mid(Txt, idxStr, 1) = Ltr
idx = idxStr + 1
idxStr = Max
Else
idxStr = idxStr + 1
idx = idxStr
End If
Loop Until idxStr >= Max
Else
idx = Max
End If
Loop Until idx >= Max
CapSentences = Txt
End If
DoCmd.Hourglass False
End Function
Public Function NextIdx(Txt As String, idxLast As Long, Max As Long) As Long
Dim x As Integer, idxBest As Long, idx As Long
x = 1
idxBest = Max
Do
idx = InStr(idxLast, Txt, Choose(x, ".", "?", "!", ":", "..."))
If idx <> 0 And idx < idxBest Then idxBest = idx
x = x + 1
Loop Until x > 5
If idxBest < Max Then
NextIdx = idxBest
Else
NextIdx = 0
End If
End Function[/blue]
[blue] Me!TextboxName = "sentence one. sentence 2."
Me!TextboxName = CapSentences(Me!TextboxName)[/blue]
[blue] variablename = "sentence one. sentence 2."
variablename = CapSentences(variablename)[/blue]
[blue]=CapSentences("sentence one. sentence 2.")[/blue]