AfterUpdate and LostFocus Events do not fire 
Author Message
 AfterUpdate and LostFocus Events do not fire

... 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



Sun, 07 Oct 2007 13:21:16 GMT  
 AfterUpdate and LostFocus Events do not fire

Quote:

> ... 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.)



Sun, 07 Oct 2007 15:31:28 GMT  
 AfterUpdate and LostFocus Events do not fire
Steve,

thanks for your answer..and your
thanks for the modifications ... of course !!! good idea
I wasn't sure at the time how many different things (space , '-', '.' ) they
might input so it was still in testing version ...

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

re the events not firing:
now I put the function call in the nextControlInTabOrder_GotFocus Event and
that way it does get executed for sure!!!
but it shouldn't be that way ...  I am using access 2k german - maybe it
should learn a bit more english ;-)

Gina



Quote:

> > ... 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.)



Sun, 07 Oct 2007 22:59:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. LostFocus Event Doesn't Fire for ActiveX TextBoxes

2. Firing AfterUpdate Event

3. Listbox - nav to rec by keystroke does not fire AfterUpdate

4. Listbox - nav to rec by keystroke does not fire AfterUpdate

5. Listbox - nav to rec by Alpha does not fire AfterUpdate

6. Form not firing AfterUpdate

7. AfterUpdate of form not firing in a Project

8. AfterUpdate of form not firing in a Project

9. Listbox - nav to rec by keystroke does not fire AfterUpdate

10. Getting lostfocus to fire./remote navigation


 
Powered by phpBB® Forum Software © phpBB Group