title: Spell Check code in MS Access form field - throws error when change is accepted
body: <p>I added the following code in the AfterUpdate event of a textbox in an MS Access form:</p>
  
  <pre><code>Private Sub txtComments_AfterUpdate()
  With Me!txtComments
      .SetFocus
      If Len(.Value) &gt; 0 Then
          DoCmd.SetWarnings False
          .SelStart = 1
          .SelLength = Len(.Value)
          DoCmd.RunCommand acCmdSpelling
          .SelLength = 0
          DoCmd.SetWarnings True
      End If
  End With
  End Sub
  </code></pre>
  
  <p>This runs a spell check when the user exits the field.  It partially works.  It opens the spell check dialogue, and locates the first error.  The problem is, when you click Ignore, Change, etc to handle/repair the spelling error, the code fails and the following error box appears:</p>
  
  <p>"The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field."</p>
  
  <p>I tried adding record-saving code before the spell check code:</p>
  
  <p>DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70</p>
  
  <p>but this didn't solve it.</p>