I am using Access 2016 and have tried running the below code as an On Exit Event to automatically spell check a Long Text field on one of my forms. When I Tab out of the field, if I spell something incorrectly, Spell Check pops up and I can correct the misspelled word and then it moves to the next field. However, the issue I am running into is that after it corrects the misspelled word it deletes the rest of the text in the box except for the word it corrected.
Private Sub AdditionalOpt_Exit(Cancel As Integer)
Dim strSpell
strSpell = AdditionalOpt
If IsNull(Len(strSpell)) Or Len(strSpell) = 0 Then
Exit Sub
End If
With AdditionalOpt
.SetFocus
.SelStart = 0
.SelLength = Len(strSpell)
End With
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End Sub
I have also tried using just the code after the "End With" statement as both On Exit and After Update Events. The code works to correct the misspelled word and doesn't delete the rest of the contents of the text box, however, the issue I have with that code is that it closes the record I'm currently working on and opens the first created record and wants to check every field on every record. Any suggestions would be appreciated. Thanks in Advance.