• Spelling checking a field (A2003)

    Author
    Topic
    #442935

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1067411

      Try this (substituting the correct control):

      Private Sub TextBox1_Exit(Cancel As Integer)
      With Me.ActiveControl
      .SelStart = 0
      .SelLength = Len(.Text)
      End With
      RunCommand acCmdSpelling
      End Sub

      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.

      • #1067415

        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!

    Viewing 0 reply threads
    Reply To: Spelling checking a field (A2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: