in

InfoPath Dev

Several Rows with same Fields to have different values when form opens

Last post 06-04-2007 01:00 AM by Matt Faus. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-25-2007 11:56 AM

    Several Rows with same Fields to have different values when form opens

    Hello,

    I'm just starting to learn InfoPath.  I am trying to create a table that will have several rows.  The columns will all have the same field binding for each row, so I guess a repeating table with a default number of rows greater than 1 is what I need.  When the user opens the form, I want a few of the columns to all have default values in them.  However, I don't want all the values to be the same, so I can't just set one default for all of them.  This will allow the user to only have to enter in the data in the columns that is unique for every row.  The reason I need the other columns with the default data present is because after the information is entered, I want to enter the data in my Access database, which requires these rows.  How can I get the form to open with these values already entered?  Thank you.

    Sincerely,

    Michael

     

  • 05-26-2007 11:32 AM In reply to

    Re: Several Rows with same Fields to have different values when form opens

    If you are going to have a database form then you will have to create the form as such from the beginning.

    If this table will have data that will submit to the database then it will have to load data from the database.  I would put your default rows in the database and then query them initially or use a stored procedure to create the new rows with the default data. Then the user can update them and submit them complete.

  • 05-30-2007 09:00 AM In reply to

    Re: Several Rows with same Fields to have different values when form opens

    Thanks, that helps a lot.  I've been reading lots of Infopath tutorials and help sections, but I'm having trouble finding how to make a simple query in a box when a form opens.  I know how to add a query field control to the form, but when I right click on it, I don't see any way to add a sql statement or something similar to the control.  Any quick advice on this?  Thanks.

     

    Michael 

  • 05-30-2007 09:23 AM In reply to

    Re: Several Rows with same Fields to have different values when form opens

    Sure.

    Hopefully you have put your query field on a form, input some data and run the query with a button and seen the resulting data.

    To automate this you have to "seed" your query field with the value you want and then run the query automatically.

    The first thing I would do is setup the query to run automatically.  I believe the easiest way is to add a rule to your field without a condition and have the action be to query your main data connection.  This way when your field changes, gets a new value, it will automatically trigger a query of your datasource. You can preview and test this by entering data and watching your datafields change.

    Then the only other part is going to tools->form options->Open->rules.  Add a rule that sets your query field's value to whatever you want. This will set your query field and therefore run your query as the form opens.  That way your data fields will have values when the user opens the form. You could also put your query rule here, and not on the field, if you only want the query to only occur at form open.

  • 05-30-2007 01:01 PM In reply to

    Re: Several Rows with same Fields to have different values when form opens

    Great, that works.  I inserted the fields that I want to be looked up upon opening the form as a repeating table (and/or section), and they look up the values successfully.  Now, however, when I add the fields that I want the user to enter, and I go to preview how it looks, there is the following problem.  The value that I enter in one of these fields is automatically copied to all the other instances of this field in the repeating section, but I need these values to be different.  Is there a way to make it so that what is entered does not copy to all of the other instances?  Thanks!
  • 06-04-2007 01:00 AM In reply to

    Re: Several Rows with same Fields to have different values when form opens

    When you edit the default values of a repeating section, they always get repeated for any other instance that is inserted.

    Instead of using Default Values to set the node values, you can use code or Rules.  If you are just setting the value of nodes that are already present in the form when it is open, then you can use Rules, but if you need to insert nodes into the XML, then you will have to use code.

    For Rules, use XPath such as node[1] = 'one', node[2] = 'two', etc.

    For code, use the insertAfter() or appendChild() methods on IXMLDOMNode.

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (6 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.