Seconday datasource based on field - InfoPath Dev
in

InfoPath Dev

Seconday datasource based on field

Last post 04-11-2007 09:33 AM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-05-2007 01:51 PM

    Seconday datasource based on field

    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,
  • 04-05-2007 02:24 PM In reply to

    Re: Seconday datasource based on field

    Use a query data source rule on the text box.
  • 04-09-2007 06:14 AM In reply to

    Re: Seconday datasource based on field

    Hi Greg,
    Thanks for the reply. This is a good step however I just can't figure out how to inject a value from my info path form into the query. Can you provide steps to do this in info path 2007?
    Thanks,
    Erin
  • 04-09-2007 08:02 AM In reply to

    Re: Seconday datasource based on field

    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( );

    }
  • 04-11-2007 09:33 AM In reply to

    Re: Seconday datasource based on field

    Looks good. Glad you got it working!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.