473,397 Members | 2,099 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,397 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(
"/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");

}





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

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

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
8
by: Tim Geiges | last post by:
Since I am being challenged with learning c# I figured I could pass some of the pain on to you guys :-) I have another question(this one is important for me to fix before I can get my app to Beta)...
2
by: wazoo | last post by:
I'm hoping someone here might help me with this. I'm putting the finishing touches on my intranet web app, and I'm adding some simple JavaScript to my VB.Net Webforms. This works:...
3
by: moondaddy | last post by:
I have some text in a page that when a certain even happens, I need to make it glow from black to red (through a spand of 1 second) pause for a few seconds, and then slowly change from red to black...
15
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px;...
20
by: d.s. | last post by:
I've got an app with two classes, and one class (InventoryInfoClass) is an object within the other class (InventoryItem). I'm running into problems with trying to access (get/set) a private...
3
by: akshaycjoshi | last post by:
IT"S A LONG QUESTION.PLEASE BE PATIENT TO READ IT. I HAVE EXPLAINED IT TO MY MAXIMUM CAPACITY. I am making one app. in which i need to create a seperate access database for each day. Its a...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.