Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    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?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    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.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    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!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •