none
DoCmd.RunCommand acCmdSpelling - causing error RRS feed

  • Question

  • User has a form with a memo text field.

    In AfterUpdate, she runs the below event procedure. This works for all users running Windows 7 but fails for one user running Windows 10. Error is

    Private Sub CSN_Notes_AfterUpdate()
        If Len(Me!CSN_Notes & "") > 0 Then
            With Me!CSN_Notes
                .SetFocus
                .SelStart = 0
                .SelLength = Len(Me!CSN_Notes)
            End With
            DoCmd.SetWarnings False
            DoCmd.RunCommand acCmdSpelling
            DoCmd.SetWarnings True
        End If
    End Sub

    Thursday, February 15, 2018 7:23 PM

All replies

  • You could try

    Private Sub CSN_Notes_AfterUpdate()
    10        On Error GoTo Error_Handler

    20         If Len(Me!CSN_Notes & "") > 0 Then
    30             With Me!CSN_Notes
    40                 .SetFocus
    50                 .SelStart = 0
    60                 .SelLength = Len(Me!CSN_Notes)
    70             End With
    80             DoCmd.SetWarnings False
    90             DoCmd.RunCommand acCmdSpelling
    100            DoCmd.SetWarnings True
    110        End If

    Error_Handler_Exit:
    120       On Error Resume Next
    130       Exit Sub

    Error_Handler:
    140       MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
                     "Error Number: " & Err.Number & vbCrLf & _
                     "Error Source: CSN_Notes_AfterUpdate" & vbCrLf & _
                     "Error Description: " & Err.Description & _
                     Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
                     , vbOKOnly + vbCritical, "An Error has Occured!"
    150       Resume Error_Handler_Exit
    End Sub

    to see which line is triggering the issue.

    That said, the error message is referring to the Before Update event and/or validation rules, do you have either?  If so, could you post the detail of those.


    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Thursday, February 15, 2018 7:32 PM
  • Also, is everyone running the full version of Access, runtime?  Same build, everyone is fully updated?

    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Thursday, February 15, 2018 7:33 PM
  • There is no BeforeUpdate event (for the field) or Validation Rule, that is why the error message is so confusing.

    However, it occurred to me, surely this should not be in AfterUpdate since if the user makes a spelling correction, how would that update be saved? Surely spell check should be in BeforeUpdate event, so if a correction is made it can be saved? How do other people do spelling check?

    Here is BeforeUpdate event for the Form.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
        Dim Response As Long
       
        Response = MsgBox("FINISHED with Edits to this Client Record?" & vbCrLf & vbCrLf & _
                          "   [YES] to SAVE CHANGES" & vbCrLf & _
                          "    [NO] to Continue Editing" & vbCrLf & _
                          "[CANCEL] to DISCARD ALL CHANGES", _
                          vbDefaultButton1 + vbQuestion + vbApplicationModal + vbYesNoCancel, _
                          "Confirm Updates to Client Record")
        If Response <> vbYes Then
            If Response = vbNo Then
                'return to editing
                Cancel = True
            Else
                If Response = vbCancel Then
                    'reverse ALL changes to record
                    Cancel = True
                    Form.Undo
                End If
            End If
        Else
            Cancel = False
        End If
       
    End Sub

    Thursday, February 15, 2018 9:13 PM
  • I do not know the details of each users MS Access version, nor do I want to get into that. There have been a few glitches with MS Access working differently for Windows 10 users compared to Windows 7 users.
    Thursday, February 15, 2018 9:15 PM
  • Hi AllTheGoodNamesWereTaken,

    Are you able to debug the code?

    If yes, Try to debug it steps by step to check the problematic line.

    Then we can try to reproduce the issue by using that line.

    It will be helpful to narrow down the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 16, 2018 2:44 AM
    Moderator
  • Thank you, I will try to narrow down the line causing the error. However, I have now been diverted onto other tasks so it make take me a few days to get back to this.
    Tuesday, February 20, 2018 5:10 PM