Repeating table - InfoPath Dev
in

InfoPath Dev

Repeating table

Last post 04-04-2006 03:50 PM by Ted Fitch. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 03-30-2006 08:48 AM

    Repeating table

    Hi, i have a repeating table in an InfoPath form.
    I have a textbox in the repeating table, which is bound to a database.
    When the user enters a value in the textbox, and clicks the "Click to insert another record" before submitting the records to the database, i would like to have the textbox in the second record to display the same value of the textbox as in the first record( which the user has already typed).How can i do this.

    Thanks.
  • 03-30-2006 10:20 AM In reply to

    Hi again,

    I think you will want to investigate using rules and using "preceding-sibling". Within that repeating table you can refer to the preceding entry (silbing) using rules to autopopulate the inserted line.

    Here are a couple of places to help you on your way in more detail:

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1741&SearchTerms=preceding-sibling

    This one deals with incremental values based upon the previous entry, but this should give you an idea of the direction you need to go:
    http://kjellsj.blogspot.com/2005/04/using-xpath-preceding-sibling-in.html

    Ted
  • 03-30-2006 11:04 AM In reply to

    I am not aware of using the XPath.
    Is there any way where i can add a rule in the properties of the repeating section.

    Thanks.
  • 03-30-2006 11:26 PM In reply to

    Hi,

    Yes, using the xPath this is what you would do. It's a little bit tricky to get it just right, but I hope that the following directions can help you figure this out:

    1) edit the properties of the repeating table

    2) Add a rule

    3) The condition is to test to see if the field is blank, then we are going to instruct InfoPath to copy the values of the preceding field into the inserted field. Name the rule whatever you want, but probably something that means something to you so you will remember what it's for in the future.

    4) Add an action

    5) The action should be to "Set a fields value". The field you choose in the Field name box should be the name of the field you want the data copied to

    6) Now we get a little tricky. Select the fx icon to the right of the value box below the This is where you are going to use InfoPath to pick the groups & fields for the command.

    In the formula section type:

    preceding-sibling::

    Then click on Insert Field or Group. Select the group that the field you want copied is part of. InfoPath may insert a "." here. If it does, manually type in the group name and this is key, add a [1] to it. This will tell InfoPath to look at the previous row to get the information to copy from. After the [1] you must put a / (which tells InfoPath which field from the group you want) Then select Insert Field or Group again and select the field and insert it. Verify the formula. If you get an error saying that it's not a valid name or a node error, you may need to add a my: in front of your group name. When I was testing this it on my machine tonight I kept having to do that. The final result should look like this:

    preceding-sibling::groupName[1]/fieldName

    Now test it. Hopefully it will work for you.

    Ted

  • 03-31-2006 09:13 AM In reply to

    Hi,
    Thanks for ur help.
    I have used the formula in the similar way, but i have an error

    formula:
    preceding-sibling::Device[1]/@Name
    Error:
    "preceding-sibling::Device/@Name" does not point to a valid location path of a field or group.

    I have also tried using "my:" before the group name but it still doesnt work.

    Thanks.
  • 03-31-2006 09:53 AM In reply to

    Sorry for the confusion on this, did you by chance use the "" around the my: when you put it in? The quotes are not part of the code...

    The other thing to try is to put the my: in front of the @Name as well.

    When I was testing this out last night (and I did get it work in the end) it seemed a little flaky at times, I had to play around with it doing different combinations to get the xpath to recognize the correct groups & fields. It did work though!

    If you send me an email through forums I will send you the actual xsn file I was playing with (I saved it) if you want. I won't be able to get to it tonight since I am not at home but I would be happy to do that for you if you want.

  • 04-03-2006 03:14 PM In reply to

    thank you very much for the file.
    But it still doesnt work for the repeating sections, may be i need to figure out using the coding part.


  • 04-03-2006 08:15 PM In reply to

    Perhaps. It took me a couple of times to get it right for me. That file is what you wanted, right? That is when you previewed the form it worked as you expected?
  • 04-04-2006 02:08 PM In reply to

    yeah, i need to make it work in the similar way.
    Thanks a lot!!!!!
  • 04-04-2006 03:50 PM In reply to

    I think you just have to play with the xpath (check the advanced check box) a little bit to get it to work. It seems like it may be somewhat buggy. Doing it with code is probably the prefered way to make it work the first time, but the wizards should work! It did take me 3 or 4 tries on each field to get it to work. I had to keep playing with it, trying different syntax. And yes, there doesn't seem anything logical about that, but it did eventually work!
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.