Hi,
I have a form in which you select a field value from an SQL db data connection, then click a button to launch another form and send that selected value to the new form. This value arrives in a query field in the new form that is connected to a similar data connection. The new form will query an SQL db based on this value when I press a Run Query button and display the results I want. My questions is how can I execute this queary when the new form opens without out having to press the run Query button?
I'm using InfoPath 2003 SP2; below is the code I'm using to set the value in the new form:
var sFormAValue = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:vw_ApplicationInformation/@AppInfoID").text;
var xdFormB = Application.XDocuments.NewFromSolution("C:\\ARP_9.xsn");
xdFormB.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s0="http://tempuri.org/" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:ns1="http://www.tempuri.org/dsFAF.xsd" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns2="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-21T16:45:01" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
xdFormB.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Glossary/@AppInfoID").text = sFormAValue;
When I tried to execute the query in the On Load Event code section it runs before the query value on the new form (target form) gets set, any ideas on how I can get this to work so it queries using the query value...thanks