An Issue with Tab Controls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JimW

    An Issue with Tab Controls

    I am using the following function which I found on the Internet to
    spell
    check certain text boxes on a form. The complete code also included
    the
    ability to spell check all text boxes that meet certain criteria. I've
    tried that version from a command button and it works perfectly.
    However, I prefer to spell check automatically upon exiting a specific
    text box by calling the function from the OnExit event. This works
    fine
    on the text boxes on the main form. However, I have text boxes on four
    tabs that I also want to check. Upon exiting any one of those text
    boxes, the form hangs up in that text box and all the text is
    highlighted in black. The only way out is to go to design view,.
    Sometimes when going to design view I get Error 2475: You entered an
    expression that requires a form to be the active window. With the
    command
    button all the designated text boxes are successfully checked whether
    on
    the main form or any of the Tab Pages.

    I call the function as follows:
    Private Sub txtDIMName_Exit (Cancel As Integer) fSpell End Sub

    Any thoughts on how to eliminate the problem with a text box on a tab
    or
    am I destined to use the command button version?

    Thanks,
    JimW

    Public Function fSpell()
    '************** *************** *************** **
    'Name: fSpell (Function)
    'Purpose: Spell check current field or fields.
    'Author: John Spencer UMBC-CHPDM
    'Date: October 31, 2002, 01:15:31 PM
    'Control on form must be a textbox and have tag property 'that
    contains
    the phrase "SpellCheck "
    '************** *************** *************** **

    Dim ctlSpell As Control
    Dim frm As Form

    '---------------------------------------------------------------------
    '---------------------------------------------------------------------
    ' Code to check a textbox control on form when called from form.
    '---------------------------------------------------------------------
    '---------------------------------------------------------------------

    On Error GoTo fSpell_Error

    Set frm = Screen.ActiveFo rm
    Set ctlSpell = frm.ActiveContr ol

    DoCmd.SetWarnin gs False ' turns off the warnings so dialog box doesn't
    '
    keep popping up for every text box saying ' spell check complete

    With ctlSpell
    If InStr(1, Nz(.Tag), "SpellCheck ", vbTextCompare) <0 And _ .Locked
    =
    False And _ .Enabled = True And _ TypeOf ctlSpell Is TextBox And _
    Len(Trim(ctlSpe ll & vbNullString)) 0 Then

    ..SetFocus
    ..SelStart = 0
    ..SelLength = Len(ctlSpell)

    DoCmd.RunComman d acCmdSpelling

    End If
    End With

    DoCmd.SetWarnin gs True ' warnings turned back on

    fSpell_Exit:
    Exit Function


    fSpell_Error:
    If Err.Number = 2474 Then
    'No Active control on current form
    'Therefore we shouldn't be spellchecking Else MsgBox Err.Number & ": "
    &
    Err.Description , , "Error in fSpell (Spell Check Routine)"
    End If
    Resume fSpell_Exit

    End Function
Working...