Hi all,
A long time ago I picked up this spell check function which I use in
the OnExit event for particular fields. I apologize to the creator of
this function for not remembering their name.
The function works fine if I'm tabbing from one field to another, or
use a custom close button to exit the form. But on certain
form/subforms I get the following error message if I try to close the
form (and its subform) using the "X" control button:
Run-time error '2474'
The expression you entered requires the control to be in the active
window.
Try one of the following:
*Open or select a form or report containing the control.
*Create a new control in the active window, and try the opereation
again.
Debug ...... End
The function is as follows:
' Put the call to the function in the "OnExit"
' OR "LostFocus" event for the required field
' as: =SpellCheck_Fie ld()
'
' Do NOT put it in the "AfterUpdat e" event
'
----------------------------------------------------------------------
' Requires the following files:
' Spelling checker (Msp*.dll, Mssp*.dll, and Mssp*.lex files)
' Hyphenator (Mshy*.dll and Mshy*.lex files)
' Thesaurus (Msth*.dll and Msth*.lex files)
' Grammar dictionary (Msgr*.lex files)
' to exist in: Program Files\Common Files\Microsoft Shared\Proof folder
(which they should)
'
----------------------------------------------------------------------
Dim frm As Form
Set frm = Screen.ActiveCo ntrol.Parent
If frm.Dirty Then
frm.Dirty = False
End If
On Error Resume Next
Dim L As Integer
L = Nz(Len(Screen.A ctiveControl), 0)
L = Len(Nz(Screen.A ctiveControl, ""))
If L 0 Then
With Screen.ActiveCo ntrol
.SetFocus
.SelStart = 0
.SelLength = L
End With
DoCmd.SetWarnin gs False
DoCmd.RunComman d acCmdSpelling
DoCmd.SetWarnin gs True
End If
End Function
'************** **********
Question:
Is there something I should adjust to this function, or some other
change I should make to my forms/subforms to fix this problem? Some
form/subform combinations don't produce this error, others do and I
can't figure out the difference.
Appreciate any help,
Mark
A long time ago I picked up this spell check function which I use in
the OnExit event for particular fields. I apologize to the creator of
this function for not remembering their name.
The function works fine if I'm tabbing from one field to another, or
use a custom close button to exit the form. But on certain
form/subforms I get the following error message if I try to close the
form (and its subform) using the "X" control button:
Run-time error '2474'
The expression you entered requires the control to be in the active
window.
Try one of the following:
*Open or select a form or report containing the control.
*Create a new control in the active window, and try the opereation
again.
Debug ...... End
The function is as follows:
' Put the call to the function in the "OnExit"
' OR "LostFocus" event for the required field
' as: =SpellCheck_Fie ld()
'
' Do NOT put it in the "AfterUpdat e" event
'
----------------------------------------------------------------------
' Requires the following files:
' Spelling checker (Msp*.dll, Mssp*.dll, and Mssp*.lex files)
' Hyphenator (Mshy*.dll and Mshy*.lex files)
' Thesaurus (Msth*.dll and Msth*.lex files)
' Grammar dictionary (Msgr*.lex files)
' to exist in: Program Files\Common Files\Microsoft Shared\Proof folder
(which they should)
'
----------------------------------------------------------------------
Dim frm As Form
Set frm = Screen.ActiveCo ntrol.Parent
If frm.Dirty Then
frm.Dirty = False
End If
On Error Resume Next
Dim L As Integer
L = Nz(Len(Screen.A ctiveControl), 0)
L = Len(Nz(Screen.A ctiveControl, ""))
If L 0 Then
With Screen.ActiveCo ntrol
.SetFocus
.SelStart = 0
.SelLength = L
End With
DoCmd.SetWarnin gs False
DoCmd.RunComman d acCmdSpelling
DoCmd.SetWarnin gs True
End If
End Function
'************** **********
Question:
Is there something I should adjust to this function, or some other
change I should make to my forms/subforms to fix this problem? Some
form/subform combinations don't produce this error, others do and I
can't figure out the difference.
Appreciate any help,
Mark
Comment