6/15/10

Spell checking a Control in a Form

If you have the full version of Office installed, and want to use the Spell Checker to check that data has been entered correctly rather than using AutoCorrect to force changes, you can use code similar to this in the AfterUpdate event for the Control:

Private Sub txtDescription_AfterUpdate()
If Len(Me!txtDescription & "") > 0 Then
With Me!txtDescription
.SetFocus
.SelStart = 0
.SelLength = Len(Me!txtDescription)
End With
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End If
End Sub

I use DoCmd.SetWarnings so that the user doesn't get a message box popping up saying that the Spelling Check is complete.

http://www.applecore99.com/frm/frm045.asp

No comments: