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 / July 2005

Tip: Looking for answers? Try searching our database.

Global Variables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger Johnson - 28 Jul 2005 22:46 GMT
Is there a way within VBScript to declare a variable as global during OnLoad?

I seem to lose the value each time I go to a different SUB, which indicates
to me that they are all local.
Scott L. Heim [MSFT] - 29 Jul 2005 13:59 GMT
Hi Roger,

When you first create an InfoPath solution, if you immediately open the
script editor (ALT+SHIFT+F11), you will see the following:

' This file contains functions for data validation and form-level events.
' Because the functions are referenced in the form definition (.xsf) file,
' it is recommended that you do not modify the name of the function,
' or the name and number of arguments.

' The following line is created by Microsoft Office InfoPath to define the
prefixes
' for all the known namespaces in the main XML data file.
' Any modification to the form files made outside of InfoPath
' will not be automatically updated.
'<namespacesDefinition>
XDocument.DOM.setProperty "SelectionNamespaces",
"xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-
29T12:56:06"""
'</namespacesDefinition>

If you simply add the following below what already exists, the variable
will be "global:"

Dim strName

You could then set that variable on the Load event of the form:

Sub XDocument_OnLoad(eventObj)
    strName = "Scott"
End Sub

And you can still access that information from the click event of a button:

Sub CTRL1_5_OnClick(eventObj)
    XDocument.UI.Alert strName
End Sub

I hope this helps! :-)

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
Roger Johnson - 29 Jul 2005 19:56 GMT
Thanks.

> Hi Roger,
>
[quoted text clipped - 40 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
 
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.