G
Gina
.... when passed via tab key or even the last letter changed ...
I wanted to change whatever string the user may type into a control to a
capital first letter
I put the call to a module func into both the AfterUpdate and the LostFocus
event of the control
If Not IsNull(Me.TypModell) Then
TypeModel = Validation.fCapitalString(Me.TypeModel.Value)
End If
I cannot put it into the before update event as I can't write at that
stage....
I put a halt onto both events .... but somehow and sometimes they do not
want to react
two days ago all worked well .... both events were halted
________________________
Public Function fCapitalString(ByVal strInString As String) As String
Dim strOut, strFirst, strRest, strTmp, strAll As String
Dim j As Long
Dim arWords, i, n
If IsNull(strInString) Then Exit Function
n = InStr(1, strInString, "-")
If n = 0 Then
arWords = Split(strInString, " ")
strOut = ""
strTmp = strInString
i = UBound(arWords)
For j = 0 To i
strFirst = UCase(Left(arWords(j), 1))
strRest = Mid(arWords(j), 2)
If j = i Then
strOut = strOut & strFirst & strRest
Else
strOut = strOut & strFirst & strRest & " "
End If
Debug.Print strOut
Next
Else
arWords = Split(strInString, "-")
strOut = ""
strTmp = strInString
i = UBound(arWords)
For j = 0 To i
strFirst = UCase(Left(arWords(j), 1))
strRest = Mid(arWords(j), 2)
If j = i Then
strOut = strOut & strFirst & strRest
Else
strOut = strOut & strFirst & strRest & "-"
End If
Debug.Print strOut
Next
End If
fCapitalString = strOut
End Function
______________
maybe it has all to do with the moon ;-)
or perhaps my code and/or wrong events ??
maybe someone has an idea for me ??
Gina
I wanted to change whatever string the user may type into a control to a
capital first letter
I put the call to a module func into both the AfterUpdate and the LostFocus
event of the control
If Not IsNull(Me.TypModell) Then
TypeModel = Validation.fCapitalString(Me.TypeModel.Value)
End If
I cannot put it into the before update event as I can't write at that
stage....
I put a halt onto both events .... but somehow and sometimes they do not
want to react
two days ago all worked well .... both events were halted
________________________
Public Function fCapitalString(ByVal strInString As String) As String
Dim strOut, strFirst, strRest, strTmp, strAll As String
Dim j As Long
Dim arWords, i, n
If IsNull(strInString) Then Exit Function
n = InStr(1, strInString, "-")
If n = 0 Then
arWords = Split(strInString, " ")
strOut = ""
strTmp = strInString
i = UBound(arWords)
For j = 0 To i
strFirst = UCase(Left(arWords(j), 1))
strRest = Mid(arWords(j), 2)
If j = i Then
strOut = strOut & strFirst & strRest
Else
strOut = strOut & strFirst & strRest & " "
End If
Debug.Print strOut
Next
Else
arWords = Split(strInString, "-")
strOut = ""
strTmp = strInString
i = UBound(arWords)
For j = 0 To i
strFirst = UCase(Left(arWords(j), 1))
strRest = Mid(arWords(j), 2)
If j = i Then
strOut = strOut & strFirst & strRest
Else
strOut = strOut & strFirst & strRest & "-"
End If
Debug.Print strOut
Next
End If
fCapitalString = strOut
End Function
______________
maybe it has all to do with the moon ;-)
or perhaps my code and/or wrong events ??
maybe someone has an idea for me ??
Gina