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 / March 2007

Tip: Looking for answers? Try searching our database.

Aaargh! OnLoad event!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Trevor Spenglehoff - 16 Mar 2007 15:30 GMT
Hi,

I'm trying to get the OnLoad programming to query an SQL 2000 database's
stored procedure to return a value. I have set up the necessary table and
credentials on the SQL server and that seems fine.

Having found a script which will do this (but not able to trace its author)
I keep getting the following error (apologies if this query is in the wrong
section, but I'm working in InfoPath and this is driving me insane):

InfoPath cannot open the selected form because of an error in the form's code.
The following error occurred:

Expected ';'
File:script.js
Line:46
{Dim CN as SqlDataSource

The actual OnLoad script is as follows:

/*
* 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-15T12:24:24" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
//</namespacesDefinition>

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/dfs:myFields/dfs:dataFields/d:tblMyID/@MyID
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd__NewID__MyID_attr::OnAfterChange(eventObj)
{
// Write code here to restore the global state.

    if (eventObj.IsUndoRedo)
        {
            // An undo or redo operation has occurred and the DOM is read-only.
            return;
        }

// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.

}

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/my:myFields/my:txtNew
// Note: Information in this comment is not updated after the function
handler is created.
//=======

function XDocument::OnLoad(eventObj)
{Dim CN as SqlDataSource
    If Xdocument.IsNew Then
        Set CN = CreateObject("ADODB.Connection")
        With CN
            .Provider = "SQLOLEDB"
            .ConnectionString = "Data Source=ACER1;Initial Catalog=Travel;Integrated
Security=SSPI"
            .Open
            .Execute "mysp_NewID"
        End With
        XDocument.DataAdapters("NewID").Query
    End If
}
Zhang Haiguang - 16 Mar 2007 16:52 GMT
It's seemed that you are writing VBScript in a JScript file.
You need to change your codes to JScript or change the script language to
VBScript.
Please reference:
http://support.microsoft.com/kb/828853
(How To: Change the Script Language for Your InfoPath Form)

InfoJet Service
InfoPath Web Form
[http://www.infojetsoft.com]
Trevor Spenglehoff - 19 Mar 2007 15:00 GMT
Excellent - you have saved me from banging my head against a brick wall -
many, MANY thanks!!!!!

> It's seemed that you are writing VBScript in a JScript file.
> You need to change your codes to JScript or change the script language to
[quoted text clipped - 6 lines]
> InfoPath Web Form
> [http://www.infojetsoft.com]
 
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.