Solved Spell Check 3 text boxes

oxicottin

Learning by pecking away....
Local time
Today, 16:46
Joined
Jun 26, 2007
Messages
891
Hello, I have 3 text boxes that are memo fields and I added a button on my form to spell check all 3. For some reason it spell checks the first 2 and skips the 3rd (txtQualityIssues) one and wont check it. The spelling is correct so that's not it, what could it be? Thanks!

Code:
Private Sub cmdSpellCheckIssues_Click()
'--------------------------------------------------------------------------------------------------
'Spell checks the 3 issues memo fields one after the other
'--------------------------------------------------------------------------------------------------

  Dim blRet As Boolean, arrCtls As Variant, i As Integer

  arrCtls = Array("txtProductionProblems", "txtMaintenanceIssues", "txtQualityIssues")
  DoCmd.SetWarnings False
  For i = 0 To UBound(arrCtls) - 1
    With Me(arrCtls(i))
      If Len(.Value & vbNullString) > 0 Then
        .SetFocus
        .SelStart = 1
        .SelLength = Len(.Value)
        DoCmd.RunCommand acCmdSpelling
        .SelLength = 0
      End If
    End With
  Next i
  blRet = (Err = 0)
End Sub
 
With only 3 textboxes, it would not hurt to walk through the code with F8?
 
I only need to check the 3 text boxes and I need to spell check one after another with a press of the button. I got the below code working correctly with @Minty suggestion for the 3 text boxes and I added true to warnings....

Code:
Private Sub cmdSpellCheckIssues_Click()
'--------------------------------------------------------------------------------------------------
'Spell checks the 3 issues memo fields one after the other
'--------------------------------------------------------------------------------------------------

  Dim blRet As Boolean, arrCtls As Variant, i As Integer

  arrCtls = Array("txtProductionProblems", "txtMaintenanceIssues", "txtQualityIssues")
  DoCmd.SetWarnings False
  For i = 0 To UBound(arrCtls) 
    With Me(arrCtls(i))
      If Len(.Value & vbNullString) > 0 Then
        .SetFocus
        .SelStart = 1
        .SelLength = Len(.Value)
        DoCmd.RunCommand acCmdSpelling
        .SelLength = 0
      End If
    End With
  Next i
  blRet = (Err = 0)
  DoCmd.SetWarnings True
End Sub
 
My point was, if you had taken the trouble to walk through the code, after all it is only 3 iterations, not 300, then the error would have been obvious?
 

Users who are viewing this thread

Back
Top Bottom