need some code changing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • savage678
    New Member
    • Oct 2008
    • 2

    #1

    need some code changing

    Hi Everyone,

    I am new to this forum and am i dire need of some help. I am trying to use wildcard searches in infopath. I have it connected to an access database using data connection.

    I have some code which will allow me to do it but i dont know how to change the code. Could someone please help me. I have added the code for you to.

    function MyQuery::OnClic k(eventObj)
    {
    // Get the default SQL command for the form.
    var strOrigSQLComma nd = XDocument.Query Adapter.Command ;

    // Get the query node that you want to modify.
    var querySuppliers = XDocument.DOM.s electSingleNode (
    "/dfs:myFields/dfs:queryFields/q:Suppliers");

    // Obtain the text that was entered for the wildcard character search, and then clear
    // the current query parameter so that InfoPath will leave the current query parameter blank.
    var strTitle = querySuppliers. selectSingleNod e("@ContactTitl e").text;
    querySuppliers. selectSingleNod e("@ContactTitl e").text = "";

    // Ask InfoPath to construct an SQL command that is based on all other field values.
    var strMySQLCommand = XDocument.Query Adapter.BuildSQ LFromXMLNodes(q ueryS uppliers);

    // Save each of the other query items, and then clear the other query items before the next query.
    var strSupplierID = querySuppliers. selectSingleNod e("@SupplierID" ).text;
    querySuppliers. selectSingleNod e("@SupplierID" ).text = "";
    var strContactName = querySuppliers. selectSingleNod e("@ContactName ").text;
    querySuppliers. selectSingleNod e("@ContactName ").text = "";
    var strPhone = querySuppliers. selectSingleNod e("@Phone").tex t;
    querySuppliers. selectSingleNod e("@Phone").tex t = "";

    // Add ContactTitle to the query so
    // that ContactTitle can support wildcard characters.
    if (strTitle != "")
    {
    if (strMySQLComman d != "")
    strMySQLCommand = strMySQLCommand + " AND ";

    strMySQLCommand = strMySQLCommand +
    "([Suppliers].[ContactTitle] LIKE \"" + strTitle + "\")";
    }

    // Construct the full query string.
    var strSQLQuery = strOrigSQLComma nd;
    if (strMySQLComman d != "")
    strSQLQuery = strSQLQuery + " WHERE " + strMySQLCommand ;

    // This is the query.
    //XDocument.UI.Al ert(strSQLQuery );

    // Run the query.
    XDocument.Query Adapter.Command = strSQLQuery;
    XDocument.Query ();

    // Restore all the user entries to the Query fields so that the user entries will
    // be available if you want to modify and to rerun the query.
    querySuppliers. selectSingleNod e("@SupplierID" ).text = strSupplierID;
    querySuppliers. selectSingleNod e("@ContactName ").text = strContactName;
    querySuppliers. selectSingleNod e("@ContactTitl e").text = strTitle;
    querySuppliers. selectSingleNod e("@Phone").tex t = strPhone;

    // Restore the default table command (for the next time).
    XDocument.Query Adapter.Command = strOrigSQLComma nd;

    // Switch to data entry view to see results.
    XDocument.View. SwitchView("Dat a Entry");

    }





    Would someone be kind enough to change it if i give them the details you need
Working...