Spellcheck only current record

J

Jay Myhre

I am using the following AfterUpdate code when exiting a text box named
Narrative:
Private Sub Narrative_AfterUpdate()
For Each ctl In Me.Controls
If ctl.Name = "Narrative" Then
ctl.Enabled = True
Else
If ctl.ControlType = acTextBox Then ctl.Enabled = False
End If
Next ctl
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
Me.Narrative.SetFocus
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then ctl.Enabled = True
Next ctl
End Sub

My problem is that some users are reporting that it occassionally checks
other records in the table, not just the one being viewed. I have the form
opened as acFormAdd and the Cycle = Current Record. Is there anything I can
add that will force it to do only the record being added?
 
G

Gina Whipp

Jay,

That is an issue, so I use the one below. I added the line * If
ctlSpell.BackColor = 15400959 Then* so that any box on a form I want spell
checked I tint that color and it only checks that one. Using a button, you
can activate with...

Private Sub cmdSpellCheck_Click()
Call Spell
End Sub

.... or on your case, on the After_Update event.


'***Start of Code
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 ctlSpell.BackColor = 15400959 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
Next
DoCmd.SetWarnings True
End Function
'**End of Code

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
J

Jay Myhre

Gina - Thanks. But won't it then spellcheck that same field in each record
or am I missing something?
What if I add something like:

Dim lngCurrentRecordID as Long
lngCurrentRecordID = Me!RecordID

If TypeOf ctlSpell Is TextBox and Me!RecordID = lngCurrentRecordID then

Would that keep it from spellchecking any record other than one currently
being viewed?

Jay
 
G

Gina Whipp

Jay,

It does not for me... It only checks the current record. Now I do use a
button but on the After_Update event of the field should work. And yes,
mine is in a continuos form. I just checked it to be sure and it stays on
the current record only. Remember you are only *toning* the field you want
spell checked.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 

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