How to Keep Spell Check On Current Record

J

JamesJ

In my access 2007 single record form I have 'Spell Check' on the shortcut
menu from a macro.
When I select 'Spell Check' it will check the current record then proceed to
check other records in the
table even though I have the Cycle property of the form set to Current
Record.
Is there any way to prevent the Spell Check from "leaving" the current
record??

Thanks,
James
 
L

Linq Adams via AccessMonster.com

Here's a hack from Arvin Meyer that does the job. Place this code in a
standard module:

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

If you use a new module, name it anything except

Spell

Using a name for a function and the module that holds it confuses the Access
Gnomes!

Now call the function like this:

Private Sub LimitedSpellCheckButton_Click()
Call Spell
End Sub

You use the code in another event if more appropriate for your need.
 
J

JamesJ

Seems to work ok but I'm getting a 'Can't move focus to MyRecordID'.
'MyRecordID'
is a hidden autonumber field. The debug window highlights '.SetFocus'.
Placing an 'On Error Resume Next' before this eliminates the error.
Although I don’t
know if that's good or bad.

James
 
D

Douglas J. Steele

It makes sense that you can't set focus to a hidden control, since focus
specifically refers to the ability of a control to accept input.

Try changing

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

to

If TypeOf ctlSpell Is TextBox Then
If ctlSpell.Visible = True Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
End If
 

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

Top