Seconday datasource based on field

E

esebastian

Hello Everyone,
New to Infopath and using infopath 2007. I would like to know how to
do the following:
I have a drop down box that lists a bunch of things. I have a field
in the datasource and when the field has a value in it i want to
filter the contents of the drop down box from the value in the
textbox. The contents of the drop down box come from the database via
a seconday datasource and it is filled when the form is opened. So
when the text changes on the field i want to re-query the drop down
box so that the contents of the drop down are based on this field...
does anyone know how to do this???
Thanks,
Erin
 
P

psiEnergos

I have not used InfoPath 2007 yet but I am sure the concept is the same; You
will need to call the secondary data connection from script (or managed code)
using the node content of the selected index of your drop down (which is tied
to an underlying XMLDOMNode)

This link explains how to do it:

http://support.microsoft.com/kb/826994

If your form is managed code then this link explains how to do it in C#
http://aspalliance.com/498

The key is the IXMLDOMDocument3 object. Just make sure you provide yu
secondary data source with parameter values and you should be good to go.

Hope this helps.
 
E

esebastian

Thanks so much for your response psiEnergos. Here is the code i used
to make this happen..

Ok i've figured this out.. here's how i've done this in infopath 2007.

if ( e.NewValue != "" )
{
DataConnection objADOAdapter;
AdoQueryConnection connection;

objADOAdapter = this.DataSources["NavigationGroups"].QueryConnection;
connection = ( (AdoQueryConnection)( objADOAdapter ) );

// Retrieve the field in the InfoPath form whose value will be used in
the WHERE clause
XPathNavigator node = this.CreateNavigator().SelectSingleNode( "/
my:myFields/my:group10/
my:cbIdentifyAssetFilterTypes",this.NamespaceManager );

if(connection.Command.Contains("inner join"))
{
//i want to remove the inner join text if there is already an inner //
join so that i can append the new join condition.
int index = connection.Command.IndexOf( "inner" );
connection.Command = connection.Command.Remove(index );
}
// Generate the new SQL statement with the INNER JOIN and WHERE clause
string strSQL = connection.Command + " inner join
linker_parent_to_child_nav l on l.childid = NavigationGroups.id where
parentid = '" + node.InnerXml + "'";

connection.Command = strSQL;

this.DataConnections["NavigationGroups"].Execute( );

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top