Spelling checking a field (A2003)

On a few occasions in the past, I've used "RunCommand acCmdSpelling" in the AfterUpdate event of a control to Spell Check the contents of the control.

What I didn't realize is that once the Spell Checker runs, it saves the current current record! I guess those few times I've used it in the past either I didn't have any BeforeUpdate code, or it just didn't encounter any problems in the BeforeUpdate event. Anyway, now I have a situation in which there is code in the BeforeUpdate event, and I don't want to save the record until later.

So, does anyone know how to spell check a control's contents without forcing the record to be saved?

Re: Spelling checking a field (A2003)

Try this (substituting the correct control):
<code>
Private Sub TextBox1_Exit(Cancel As Integer)
With Me.ActiveControl
.SelStart = 0
.SelLength = Len(.Text)
End With
RunCommand acCmdSpelling
End Sub
</code>
By selecting the text in the control, the spell check is limited to this text. This cannot be done in the Before Update or After Update event of the control, you get an error message. The On Exit event seems to work well.

Re: Spelling checking a field (A2003)

Hans,

Thanks, you are a life-saver. Weird that it only works in OnExit!

While on my walk, I did come up with another way to handle, but didn't have a chance to test it. Involved setting a form-level flag indicating the spell checker had been invoked. I could then Cancel out of BeforeUpdate if this variable was set (while turning-off the flag). Glad I didn't have to try it!