By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Function SpellCheck_Field()

P: n/a
cmd
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_Field()
'
' Do NOT put it in the "AfterUpdate" 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.ActiveControl.Parent

If frm.Dirty Then
frm.Dirty = False
End If
On Error Resume Next
Dim L As Integer
L = Nz(Len(Screen.ActiveControl), 0)
L = Len(Nz(Screen.ActiveControl, ""))
If L 0 Then
With Screen.ActiveControl
.SetFocus
.SelStart = 0
.SelLength = L
End With

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings 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

Jul 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
cmd
.... apologies ... I forgot to mention that it errors at the line:
Set frm = Screen.ActiveControl.Parent

c...@mountain.net wrote:
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_Field()
'
' Do NOT put it in the "AfterUpdate" 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.ActiveControl.Parent

If frm.Dirty Then
frm.Dirty = False
End If
On Error Resume Next
Dim L As Integer
L = Nz(Len(Screen.ActiveControl), 0)
L = Len(Nz(Screen.ActiveControl, ""))
If L 0 Then
With Screen.ActiveControl
.SetFocus
.SelStart = 0
.SelLength = L
End With

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings 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
Jul 22 '06 #2

P: n/a
cmd
.... apologies ... I forgot to mention that it errors at the line:
Set frm = Screen.ActiveControl.Parent

c...@mountain.net wrote:
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_Field()
'
' Do NOT put it in the "AfterUpdate" 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.ActiveControl.Parent

If frm.Dirty Then
frm.Dirty = False
End If
On Error Resume Next
Dim L As Integer
L = Nz(Len(Screen.ActiveControl), 0)
L = Len(Nz(Screen.ActiveControl, ""))
If L 0 Then
With Screen.ActiveControl
.SetFocus
.SelStart = 0
.SelLength = L
End With

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings 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
Jul 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.