>I think I see what the problem is. Screen.ActiveForm refers to the main
>form. The subform is a mere control on the main form, a picture box, if you
>will. You must refer to the Form property of the subform control. So, I'm
>not sure that you can run this code from a module. Try running it from
>inside the subform as a function. You can do that like:
>
> Private Sub cmdSpell_Click()
> Dim ctlSpell As Control
> DoCmd.SetWarnings False
> ' Enumerate Controls collection.
> For Each ctlSpell In Me.Controls
> If TypeOf ctlSpell Is TextBox Then
> If Len(ctlSpell) > 0 Then
> With ctlSpell
> .SetFocus
> .SelStart = 0
> .SelLength = Len(ctlSpell)
> End With
> DoCmd.RunCommand acCmdSpelling
> End If
> End If
> Next
> DoCmd.SetWarnings True
> End Sub
>
> which was the original code I wrote 10 years ago, before I converted it to
> a standard module.
> --
> Arvin Meyer, MCP, MVP
>
http://www.datastrat.com>
http://www.mvps.org/access>
http://www.accessmvp.com>
>
> "Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
> news:uFwE9DMXJHA.5980[ at ]TK2MSFTNGP04.phx.gbl...
>> Arvin,
>>
>> My code runs fine against textboxes on the main form. But bombs when run
>> in a textbox on a subform.
>>
>> When I open the form that is the source object for the subform, and run
>> the code there (as if it were a main form) it works just fine.
>>
>> I have run into this problem at home and at work. Allen Browne mentioned
>> a couple of months ago that he would try to take a look at it, but that
>> was shortly after he started his new job, and I have not heard back from
>> him.
>>
>> I was hoping he or one of you MVPs would try to duplicate the problem,
>> and then bring it to the attention of the guys at Microsoft.
>>
>> Have you actually tried to implement this in a subform in Office 2007?
>>
>> Dale
>>
>>
>> "Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> wrote in message
>> news:%23J8S9WBXJHA.1328[ at ]TK2MSFTNGP02.phx.gbl...
>>> This the only code that is really active for spelling:
>>>
>>> DoCmd.RunCommand acCmdSpelling
>>>
>>> Try putting that in a function on the double-click event of 1 text box.
>>> If you get an error, It may be because you do not have your database in
>>> a Trusted location and have code enabled. It should run, and if this
>>> runs, everything else should as well.
>>> --
>>> Arvin Meyer, MCP, MVP
>>>
http://www.datastrat.com>>>
http://www.mvps.org/access>>>
http://www.accessmvp.com>>>
>>> "Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
>>> news:eoxojeyWJHA.4768[ at ]TK2MSFTNGP04.phx.gbl...
>>>> Arvin,
>>>>
>>>> Tried it, but am still getting the same error and Access abort (mot
>>>> much difference between this and my code anyway, except looking at all
>>>> textboxes on the form, rather than only one).
>>>>
>>>> I've been having this problem ever since we moved to Office 2007, and
>>>> it has happened on each of the three computers I've had during that
>>>> period.
>>>>
>>>> I've figured out that I can use F7 to do a spell check, and that seems
>>>> to work, although it appears to be doing it for every record in the
>>>> main table, rather than only the current record.
>>>>
>>>> Any other suggestion would be considered.
>>>>
>>>> Dale
>>>>
>>>>
>>>> "Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> wrote in message
>>>> news:%23Z3a$bvWJHA.4632[ at ]TK2MSFTNGP04.phx.gbl...
>>>>> Try this one. It's worked on all versions of Access in the last 11
>>>>> years:
>>>>>
>>>>> Public Function Spell()
>>>>> ' Arvin Meyer 9/17/1998
>>>>> ' Adapted from code by Terry Wickenden
>>>>> Dim ctlSpell As Control
>>>>> Dim frm As Form
>>>>> Set frm = Screen.ActiveForm
>>>>> DoCmd.SetWarnings False
>>>>> ' Enumerate Controls collection.
>>>>> For Each ctlSpell In frm.Controls
>>>>> If TypeOf ctlSpell Is TextBox Then
>>>>> If Len(ctlSpell) > 0 Then
>>>>> With ctlSpell
>>>>> .SetFocus
>>>>> .SelStart = 0
>>>>> .SelLength = Len(ctlSpell)
>>>>> End With
>>>>> DoCmd.RunCommand acCmdSpelling
>>>>> End If
>>>>> End If
>>>>> Next
>>>>> DoCmd.SetWarnings True
>>>>> End Function
>>>>> --
>>>>> Arvin Meyer, MCP, MVP
>>>>>
http://www.datastrat.com>>>>>
http://www.mvps.org/access>>>>>
http://www.accessmvp.com>>>>>
>>>>>
>>>>> "Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
>>>>> news:0B8F0856-C642-4971-8296-3280088D7416[ at ]microsoft.com...
>>>>>> I'm still having spell check problems.
>>>>>>
>>>>>> I posted a note message to this board back in September, and never
>>>>>> did
>>>>>> resolve the problem. I've worked on several other applications since
>>>>>> then,
>>>>>> and have never resolved the problem I'm having with a spellcheck
>>>>>> function
>>>>>> that I allow users to call via a shortcut menu. If they are in a
>>>>>> textbox on
>>>>>> the main form, the function appears to run successfully, but if the
>>>>>> control
>>>>>> that has the focus is on a subform, running this function causes
>>>>>> Access
>>>>>> (2007) to lock up.
>>>>>>
>>>>>> Public Function fnTextSpell()
>>>>>>
>>>>>> Dim frm As Form
>>>>>> Dim ctrl As TextBox
>>>>>>
>>>>>> 'define the form that the popup was actually called from
>>>>>> Set frm = Screen.ActiveForm
>>>>>> While frm.ActiveControl.ControlType = 112
>>>>>> Set frm = frm.ActiveControl.Form
>>>>>> Wend
>>>>>>
>>>>>> 'Define the control on that form that has the focus
>>>>>> Set ctrl = frm.ActiveControl
>>>>>>
>>>>>> 'if no text is selected in the control, then select all the text
>>>>>> With ctrl
>>>>>> If ctrl.SelLength = 0 Then
>>>>>> ctrl.SelStart = 0
>>>>>> ctrl.SelLength = Len(ctrl.Text)
>>>>>> End If
>>>>>> End With
>>>>>>
>>>>>> 'Run the spellchecker against the selected text
>>>>>> ' DoCmd.RunCommand acCmdSpelling
>>>>>> Application.RunCommand acCmdSpelling
>>>>>>
>>>>>> End Function
>>>>>>
>>>>>> Everything runs correctly, right up to the Runcommand acCmdSpelling,
>>>>>> but
>>>>>> when the code encounters that line, I get the following warning
>>>>>> message.
>>>>>> And, as you can see, I've tried both docmd.runcommand and
>>>>>> application.runcommand, both result in the same error and Access
>>>>>> shutdown.
>>>>>>
>>>>>> Microsoft Office Access has stopped working
>>>>>>
>>>>>> Windows can try to recover your information and restart the program.
>>>>>>
>>>>>> This most recent application involves a lot of long memo fields (on
>>>>>> subforms) , and I would really like my users to be able to use the
>>>>>> spell
>>>>>> checker. Any help would be greatly appreciated.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> HTH
>>>>>> Dale
>>>>>>
>>>>>> email address is invalid
>>>>>> Please reply to newsgroup only.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>