473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

USing wildcard searchs in Infopath using VB

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(
"/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.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.
//XDocument.UI.Alert(strSQLQuery);

// Run the query.
XDocument.QueryAdapter.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.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");

}
Oct 16 '08 #1
0 2652

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

Similar topics

0
by: Victor Hadianto | last post by:
Hi all, Based on this post: http://groups.google.com/groups?q=mso-application&hl=en&lr=&selm=6n%23mkFJREHA.3744%40cpmsftngxa10.phx.gbl&rnum=8 And by doing a bit of reverse engineering how...
4
by: Jon Westmore | last post by:
I'm using an ASP page to dynamically generate an XML document using a data source. I was thinking the concept would be similar to dynamically creating HTML but I'm running into an issue. Here is...
3
by: Jon Westmore | last post by:
I've been trying to use a combination of ASP and Infopath to display a dynamic form for users to fill out. I have some ASP code that generates a dynamic XML document and the document points to the...
4
by: MJ | last post by:
A question for InfoPath and ASP.NET experts: What do you think about the future of InfoPath and ASP.NET WebForms? Is InfoPath 12 going to replace ASP.NET WebForms? If not, in which types of...
0
by: Cosimo Galasso | last post by:
I'm building a aspx web page with a button control. When the button is clicked the server build an xml string containg the directive to be opened with infopath. When the client receive the file an...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
0
by: Sebastian Gingter | last post by:
I have an infopath XML file and want to use XPath queries with the XmlDocument object. The Problem: Every (in my eyes correct) XPath query does return a NULL object. Example: XmlDocument doc =...
0
by: =?Utf-8?B?Q2hhcmxlcyBTaW1wc29u?= | last post by:
Hello I've tried in the InfoPath groups but no luck yet. Here is my situation: All computers are on an Active Directory domain in the company. I have an Infopath form stored on the network...
0
by: Anni | last post by:
Hi, Can anyone please tell me how do I give same namespace for different infopath forms.? I have an XML formed by an infopath form, the XML is : <?mso-infoPathSolution...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.