Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / January 2006

Tip: Looking for answers? Try searching our database.

VBscript error for script on OnAfterChange Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cmenconi@techie.com - 27 Jan 2006 19:09 GMT
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.

--Script------
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
--end script-----

Any help would be much apperciated... Thanks!
bratt - 30 Jan 2006 15:19 GMT
Since you are changing the object in a onafterchange event on it you
will fire the event yourself.  you can setup a semaphore flag to only
execute the code once:

dim ModifyItem = false
Sub msoxd_my_txtServerName_OnAfterChange(eventObj)

' Write code here to restore the global state.

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

ModifyItem = true ' make sure this code is only executed once
' 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)
ModifyItem = false  ' set it back to complete for next time
End Sub
cmenconi@techie.com - 30 Jan 2006 16:50 GMT
bratt

Thanks a Million man!

That worked great.

>Since you are changing the object in a onafterchange event on it you
>will fire the event yourself.  you can setup a semaphore flag to only
[quoted text clipped - 19 lines]
>ModifyItem = false  ' set it back to complete for next time
>End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.