Results 1 to 11 of 11
  1. #1
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87

    Autorun of Spell check

    I have a form that has a three separate memo fields that I would like to have Spell check run after updating and tabbing out of the control. I am using the following code in the After Update event:



    If Len(Me!AdditionalOpt & "") > 0 Then
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdSpelling
    DoCmd.SetWarnings True
    Else
    Exit Sub
    End If

    It works great except for one thing. Once I tab out of the memo field the Spell Check dialog box will open and allow me to correct any misspellings. Then when I go to the next field, enter the data, and hit tab, all of the data that I previously entered disappears (which is 17 fields including the AdditionalOpt field). I get no error messages. The previous data entered just disappears.

    I can set it up to run spell check via button but would prefer to have it run automatically after exiting the control. Any ideas? Thanks in advance.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  3. #3
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Thanks Orange. I actually saw that post previously and I tried the code but for some reason I would get the message stating that Spell checking was complete but the Spell check dialog box would not display. I found some other code that I tried for the On Exit event and the same thing happened. The Spell check dialog box would not display and would just get the message stating that the Spell checking was complete. I also tried some code that I found for the On Lost Focus event that another user posted here with the same results.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    If there are no spelling mistakes does the dialog box still display? I googled but didn't find an answer...

    I wrote a very small routine and confirmed that
    -if there are no spelling errors, the spelling dialog does not pop-up,
    -if there is an error, you'll see the dialog box with options.

    I used the On Exit event and the code from HansUp.

  5. #5
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Quote Originally Posted by orange View Post
    If there are no spelling mistakes does the dialog box still display? I googled but didn't find an answer...

    I wrote a very small routine and confirmed that
    -if there are no spelling errors, the spelling dialog does not pop-up,
    -if there is an error, you'll see the dialog box with options.

    I used the On Exit event and the code from HansUp.
    I purposefully misspelled a word for the On Exit event and the On Lost Focus event. Both times I received the same result where I received the message that Spell Checking was complete and the spelling dialog doesn't pop-up. I'll have to try it again on Monday. Maybe I mistyped some of the code. Thank you.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    If you can't get yours to work on Monday, here is an alternative spell check code by Terry Wickenden that I've used for many years

    Code:
    '########################################################################
    '#  Allows spell check of a control (it must be a text box)
    '########################################################################
    Public Sub SpellCheckControl(ctlSpell As control)
    ' Adaptation by Terry Wickenden of code
    ' from Microsoft Knowledge Base
    
       If TypeOf ctlSpell Is TextBox Then
         If ctlSpell.Locked = False And ctlSpell.visible = True Then
            If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
              'MsgBox "There is nothing to spell check."
              ctlSpell.SetFocus
              Exit Sub
            End If
            With ctlSpell
              .SetFocus
              .SelStart = 0
              .SelLength = Len(ctlSpell)
            End With
            DoCmd.SetWarnings False
            DoCmd.RunCommand acCmdSpelling
            DoCmd.SetWarnings True
          End If
       ElseIf TypeOf ctlSpell Is SubForm Then
         If ctlSpell.Locked = False And ctlSpell.visible = True Then
            If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
              'MsgBox "There is nothing to spell check."
              ctlSpell.SetFocus
              Exit Sub
            End If
            With ctlSpell
              .SetFocus
              .SelStart = 0
              .SelLength = Len(ctlSpell)
            End With
            DoCmd.SetWarnings False
            DoCmd.RunCommand acCmdSpelling
            DoCmd.SetWarnings True
          End If
       Else
         MsgBox "Spell check is not available for this item."
       End If
       ctlSpell.SetFocus
    End Sub
    Usage: call a routine like this to spell check all 3 textbox controls just before closing your form
    OR do them individually as preferred

    Code:
    Private Sub RunSpellCheck()    
        SpellCheckControl Me.Textbox1
        SpellCheckControl Me.Textbox2
        SpellCheckControl Me.Textbox3
        
    End Sub
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Quote Originally Posted by ridders52 View Post
    If you can't get yours to work on Monday, here is an alternative spell check code by Terry Wickenden that I've used for many years
    Thank you for the post. I'll try that as well.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I thought I should post a copy of my mock up.
    The base code came from HansUp's comment at https://stackoverflow.com/questions/...ge-is-accepted


    Type anything into text0, the spell check gets executed when you exit the textbox.
    Try it with/without spelling errors.

    Good luck.
    Attached Files Attached Files

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Topflite66 View Post
    ...when I go to the next field, enter the data, and hit tab, all of the data that I previously entered disappears (which is 17 fields including the AdditionalOpt field)...The previous data entered just disappears...
    This sounds an awful lot like the Cycle Property (Properties - Other - Cycle) is set to All Records (the default) and you're actually moving to a new Record. Is this happening when you Tab out of the last Control on the Form? If so, try changing Cycle Property to Current Record and see if that works.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Quote Originally Posted by Missinglinq View Post
    This sounds an awful lot like the Cycle Property (Properties - Other - Cycle) is set to All Records (the default) and you're actually moving to a new Record. Is this happening when you Tab out of the last Control on the Form? If so, try changing Cycle Property to Current Record and see if that works.
    I just realized that I may have inadvertently left out a key piece of information. The form I am working with is based on two related tables, tbl_VehicleDetails and tbl_OrderDetails. After I read your post Missinglinq about "moving to a New Record", I checked the tbl_VehicleDetails table and there were several instances of the same record from when I was attempting to get the spell check code to work. When I would tab out of the last Vehicle Details Control to the first Order Details Control of the form, Access would save the data in the Vehicle Details table and create a new record (which would make the data "disappear"). I'm wondering if because the form is built on the two tables that may be causing my problems?

    Is there a work-a-round for this? If not then I'm thinking I have two options: Create a query and base the form on the query or merge the two tables. Any suggestions as to which would be a better option? One thing I should mention is that the controls for Vehicle Details section need to be cascading combo boxes, which I have set up in my current form.

    Sorry for the confusion and Thank you.
    Last edited by Topflite66; 04-03-2018 at 12:24 PM.

  11. #11
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    I created a join query and based the form on that query and I still had the same issue. Then I merged the two tables and then set the record source as the new table. That seemed to work with the original code that I posted in my first post. So I added the code to the other two memo fields and they work also. Thank you all for your help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto Spell Check in Form Field
    By Njliven in forum Forms
    Replies: 7
    Last Post: 04-26-2017, 07:44 AM
  2. trying to turn off spell check for sent emails
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 02-13-2014, 08:05 PM
  3. Spell and grammar check
    By destroyer in forum Forms
    Replies: 1
    Last Post: 01-19-2014, 11:51 AM
  4. Suppress spell check error message
    By sabre1 in forum Forms
    Replies: 1
    Last Post: 03-24-2011, 09:58 AM
  5. Code to spell out check amount?
    By spkoest in forum Access
    Replies: 4
    Last Post: 06-16-2009, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums