VBscript error for script on OnAfterChange Event - InfoPath Dev
in

InfoPath Dev

VBscript error for script on OnAfterChange Event

Last post 01-27-2006 09:50 AM by cmenconi. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-27-2006 08:33 AM

    VBscript error for script on OnAfterChange Event

    I am having an issue with a vbscript set to run as a Data Validation script triggered by an OnAfterChange event.

    The Error I get is An error occurred in the form's code. The number of calls to the OnAfterChange event for a single update in the data exceeded the maximum limit.

    I have found a few articals on this error but all of them pointed to jscript which I am unfamiliar with.


    Sub msoxd_my_txtServerName_OnAfterChange(eventObj)

    ' Write code here to restore the global state.

    If eventObj.IsUndoRedo Then
    ' An undo or redo operation has occurred and the DOM is read-only.
    Exit Sub
    End If

    ' A field change has occurred and the DOM is writable. Write code here to respond to the changes.
    Dim objServerName
    Set objServerName = XDocument.DOM.selectSingleNode("//my:myFields/my:txtServerName")
    objServerName.text = ucase(objServerName.text)
    End Sub


    Any help would be much apperciated... Thanks!
  • 01-27-2006 09:24 AM In reply to

    Re: VBscript error for script on OnAfterChange Event

    This code is causing an infinite loop. When you use "objServerName.text = ucase(objServerName.text)" it calls the OnAfterChange event of that node (which is itself) and causes recursion.

    Greg Collins has written a HowTo on this issue, it can be found here:
    http://infopathdev.com/howto/tips/default.aspx?i=3551199a23ac41f3a155b3a2ffc412c5

    You will use a boolean variable to indicate whether it is the code changing the value of the field or the user.

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-27-2006 09:50 AM In reply to

    Re: VBscript error for script on OnAfterChange Event

    Matt

    Thanks for the pointer, I had read this artical prevously but Unfortunitly all of greg's examples are in jscript and I am working in vbscript and am having troubles adapting the concepts between the two
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.