I have code to spell check a particular field ( Notes). However when I tried to add spell check another field I get a run time error (2185). I have searched Google, but was not successful in finding a resolution to the problem.
Spellcheck works on the Notes field using "On Lost Focus" Here is the code:
Private Sub Notes_LostFocus()
With Me!Notes
If Len(.Value) > 0 Then
DoCmd.SetWarnings False
.SelStart = 1
.SelLength = Len(.Value)
DoCmd.RunCommand acCmdSpelling
.SelLength = 0
DoCmd.SetWarnings True
End If
End With
End Sub
When I tried to do spell check on another field (Application Method). I receive error messages, depending on where I place the code. If I use the same code as above & replace
With Me!Notes with With Me!Application Method on lost focus, I get a run time error of 2185. If I use different code & place it on exit, I get a syntax error, & it hangs on With Me!Application Method . Here
is the code that I used on exit:
Private Sub Application_Method_Exit(Cancel As Integer)
With Me!Application Method
If Len(.Value) > 0 Then
DoCmd.SetWarnings False
.SelStart = 1
.SelLength = Len(.Value)
DoCmd.RunCommand acCmdSpelling
.SelLength = 0
DoCmd.SetWarnings True
End If
End With
I am very confused. Could you please explain the difference between "On Lost Focus" & on exit. Which is better, & how I can fix the problem, so the code runs?
***Post moved by the moderator to the appropriate forum category.***