Spell check still causing problems

D

Dale Fye

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.
 
A

Arvin Meyer [MVP]

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
 
D

Dale Fye

Thanks for the post Arvin, but no good.

This code is almost identical to my code (except that it looks at all of the
textboxes on the form), which I've used for as long as I can remember, but it
is not working in 2007 (at least not on subforms). I don't even have the
same computer I had a week ago, so it cannot be the computer.

It works fine (as does pressing F7) in the main form, but when I run the
code by right clicking in a textbox on a subform, and then selecting the
Spell Check option, it locks up at the Docmd.RunCommand line. BTW, F7 works
in the subforms, so I have a work-around, but would really like to get this
shortcut code working properly.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dale Fye

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
 
D

Dale Fye

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
 
A

Arvin Meyer [MVP]

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
 
D

Dale Fye

Arvin,

I know I can add that code into the form, but wanted to eliminate all of
that redundant code (having spell check code imbedded in every form seems
like a real waste of code). My textbox shortcut menu contains all of the
starnard (Copy, Cut, Paste) as well as Spell Check and Find options. Each
of these options runs a custom function or subroutine that is located in my
MenuFunctions code module. All of these other functions work when dealing
with subforms, but not the spell check.

I thought that these lines:

Set frm = Screen.ActiveForm
While frm.ActiveControl.ControlType = 112
Set frm = frm.ActiveControl.Form
Wend

Would take care of that. As long as the "ActiveControl" is a subform, I keep
drilling down, redefining the frm variable as the active control, and then
tacking on the .Form suffix. This seems to work, because the succeeding
lines

'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

that define the textbox that is the actual control that has the focus works
when it highlights all of the text in the box if none is already highlighted
works fine.

Still confused.

Dale
 
A

Arvin Meyer [MVP]

Dale Fye said:
Arvin,

I know I can add that code into the form, but wanted to eliminate all of
that redundant code (having spell check code imbedded in every form seems
like a real waste of code). My textbox shortcut menu contains all of the
starnard (Copy, Cut, Paste) as well as Spell Check and Find options. Each
of these options runs a custom function or subroutine that is located in
my MenuFunctions code module. All of these other functions work when
dealing with subforms, but not the spell check.


Still confused.

I think Access may be confused as well. It may well be that the only way to
achieve success is to put the code inside the subform. Sometimes we need to
take a well travelled path, instead of trying to forge a new road.
 
D

Dale Fye

Arvin,

Thanks for your input. I'll continue to pursue this, but will, at least for
the time being, settle on your solution.

Dale
 
D

Dale Fye

Arvin,

I just tested this again at home (where I have 2002, 2003, and 2007 all
running on the same box).

I created a simple Access 2003 application (two tables), two forms (form and
subform), and copied my menu and spell check funtion into the database.

The code runs flawlessly in 2003 (both in the main form, and the subform).

When I created a new mdb in 2007, and imported the tables, forms, and code
into that database, it locked up as soon as I tried to run the code from the
subform. Same thing happened when I created a new accdb from scracth and
imported the tables, forms and code.

This is a BUG, that needs to be addressed to the folks at MS.

Hope you will pass this on!
 
D

Dale Fye

Arvin,

I was finally able to get ahold of the Access development team at Microsoft
(used their blog site to send a message). They acknowledged that the problem
existed in Access 2007, as recently as SP1, but they indicate that it has
been resolved in one of the recent hotfixes.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Spell Check problems in Access 2007 3
Spell Check 4
Spell check resets listbox 12
Spell Check Help 1
Spell check of form and subform 1
spell check 1
Spell Check Help 2
Spelling isn't available now 1

Top