Prevent double entries in repeating table - InfoPath Dev
in

InfoPath Dev

Prevent double entries in repeating table

Last post 07-13-2005 03:37 PM by Agni Jonnalagadda. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-13-2005 09:26 AM

    Prevent double entries in repeating table

    I have a repeating table in my form with the fields product number, Product and Quantity. These table is linked with a secondary data source on my SQL Server where all products are listed. The user files in the product number in the table. The product field comes then from the secondary data source. With a data validation I check if the product number is existing in the data source.

    Now to my problem:
    It#%92s important that no double product numbers can be filled in in the repeating table. How can I prevent double entries in these repeating table?

    Thanks for your help!

    Benny

  • 07-13-2005 10:02 AM In reply to

    Re: Prevent double entries in repeating table

    Hi Benny,
    Welcome to the forum!
    Even I had a similar problem before. I dint get a way to do this in InfoPath. So i had write code for this.

    Agni
    InfoPathDev India
  • 07-13-2005 01:40 PM In reply to

    Re: Prevent double entries in repeating table

    Hi Agni

    Thanks for your fast answer.
    Hmm, unfortunately i'm a newbie in coding. Can you give me support for the beginning. Some kind of code for demo?

    Could there be an other possibility if i merge the double entries when i store the data in my database?
    In these case, the entries in the quantity fields must adds. Is the perhaps a solution?

    Thanks Benny
  • 07-13-2005 03:15 PM In reply to

    Re: Prevent double entries in repeating table

    Hi ,

    Try this:

    Each time the user inputs in the field, On_After_Change, check the previous entries in the previous rows in the table:

    For this you need to have a RowCount,
    ( Right clck on my:fileds, and add a text field,name it rowcounter ) , and for the value have the following xpath:
    count(../my:Choices/my:Choice) , where the Choice is the name of the table that repeats.
    Now you have a rowcounter that updates each time.
    to get this in integer form in your code you do this:

    int rc = System.Convert.ToInt16( thisXDocument.DOM.selectSingleNode("/my:myFields//my:rowcounter").text);



    On_After_Change for the field you want, do something like this:

    for (i = 1;i<= rc ;i++)
    {
    // compare your current text with this for every row, except the current one.
    thisXDocument.DOM.selectSingleNode("/my:myFields//my:Choices/my:Choice["+System.Convert.ToString(i)+"]/my:productnumber").text ;

    }
    or build an xpath filter excluding the previous row values.

    Hope this helps..

  • 07-13-2005 03:37 PM In reply to

    Re: Prevent double entries in repeating table

    //get new value of the present row
    string sNewValue = e.NewValue.ToString();

    //get the repeating nodes, "RepeatingNode" here you need to write the xpath so that you will get only the nodes which are equall to the new value

    IXMLDOMNodeList oNodeList = getNodes(string.Format("//RepeatingNode[. = {0}]", sNewValue));

    //check if the length of the nodelist is greater than 1
    if(oNodeList.length > 1)
    return;
    else
    //throw an error and empty the present node


    Agni
    InfoPathDev India
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.