471,324 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,324 software developers and data experts.

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::OnClick(eventObj)
// Get the default SQL command for the form.
var strOrigSQLCommand = XDocument.QueryAdapter.Command;

// Get the query node that you want to modify.
var querySuppliers = XDocument.DOM.selectSingleNode(

// 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.selectSingleNode("@ContactTitle").t ext;
querySuppliers.selectSingleNode("@ContactTitle").t ext = "";

// Ask InfoPath to construct an SQL command that is based on all other field values.
var strMySQLCommand = XDocument.QueryAdapter.BuildSQLFromXMLNodes(queryS uppliers);

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

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

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

// Construct the full query string.
var strSQLQuery = strOrigSQLCommand;
if (strMySQLCommand != "")
strSQLQuery = strSQLQuery + " WHERE " + strMySQLCommand;

// This is the query.

// Run the query.
XDocument.QueryAdapter.Command = strSQLQuery;

// 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.selectSingleNode("@SupplierID").tex t = strSupplierID;
querySuppliers.selectSingleNode("@ContactName").te xt = strContactName;
querySuppliers.selectSingleNode("@ContactTitle").t ext = strTitle;
querySuppliers.selectSingleNode("@Phone").text = strPhone;

// Restore the default table command (for the next time).
XDocument.QueryAdapter.Command = strOrigSQLCommand;

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


Would someone be kind enough to change it if i give them the details you need
Oct 16 '08 #1
0 889

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Chris Reedy | last post: by
48 posts views Thread by Chad Z. Hower aka Kudzu | last post: by
8 posts views Thread by Tim Geiges | last post: by
2 posts views Thread by wazoo | last post: by
3 posts views Thread by moondaddy | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.