Consulting

Results 1 to 3 of 3

Thread: Solved: Exit behaviour for last field in a frame

  1. #1

    Solved: Exit behaviour for last field in a frame

    Hi.

    I have a large number of text boxes on a form, split into eight separate frames. I've got code to handle input validation for each textbox, ensuring that only numeric data is entered. It is triggered in the Exit event for the control. This is working fine for every textbox within a frame *except* the very last one, in which case no error message will appear and focus moves to the first box of the next frame. It seems almost as if leaving the very last textbox of a frame is simply not triggering the Exit event at all.

    Here's the code I'm using:


    Private Sub txtInput1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    If VerifyNumbers(frmInputSession.txtInput1) = False Then
    Cancel = True
    End If

    End Sub

    Function VerifyNumbers(Ctrl As Object) As Boolean

    VerifyNumbers = True

    If Ctrl.Name Like "txtInput*" Then
    With Ctrl
    If Not IsNumeric(.Value) And .Value <> "" Then
    MsgBox "Sorry, only numbers allowed."
    .Value = ""
    VerifyNumbers = False
    End If
    End With
    End If

    End Function

    So, just to reiterate, this is functioning perfectly fine for every textbox control on the form, except those that happen to be the last one of a frame. So that means of 34 textboxes in 8 frames, only 26 work properly.

    Oddly enough though, code seems to execute when I move back to that control with a mouse click.

    Aside from the control names (txtInput*), the code is identical for every one of those 34.

    Can anyone tell me what's up with this?

    Thanks.

  2. #2
    Never mind.

    Removed the frames. Works fine now.

  3. #3
    VBAX Regular
    Joined
    Jun 2007
    Posts
    69
    Location
    devolved,

    If this is now closed, please mark it that way. Click on the down arrow by Thread Tools in the tool bar and click Mark Solved and then the Perform Action button.

    Thanks,
    Ron McKenzie
    Windermere, FL
    (living in the huge shadow of a tiny rodent)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •