well .... I was kind of very tired after about 20 hours at the pc yesterday
.... I am translating the names of my controls and ( if necessary) funktions
etc
from german to english ... so it does make it easier for the english
speaking rest of the worls.- that was the reason for the misspelling
> > ... 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 think there is a typo: is it "TypModell" or "TypModel"?
> > If Not IsNull(Me.TypModell) Then
> ^^ two L's
> > TypeModel = Validation.fCapitalString(Me.TypeModel.Value)
> ^ one L
> > End If
> I don't understand the "Validation" part. Try calling the function using:
> TypeModel = fCapitalString(Me.TypeModel)
> Also, I hope you don't mind... I modified your code a little. The code in
the
> second "IF..Else..End IF" was duplicated.
> ' *** begin code *******
> Public Function fCapitalString(ByVal strInString As String) As String
> Dim strOut As String, strFirst As String
> Dim strRest As String, strTmp As String, strAll As String
> Dim j As Long, i As Integer, n As Integer
> Dim arWords()
> If IsNull(strInString) Then Exit Function
> n = InStr(1, strInString, "-")
> If n = 0 Then
> arWords = Split(strInString, " ")
> Else
> arWords = Split(strInString, "-")
> End If
> ' this was the same code
> 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
> fCapitalString = strOut
> End Function
> ' ****** end code ****
> --
> Steve
> --------------------------------
> "Veni, Vidi, Velcro"
> (I came, I saw, I stuck around.)