<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Controls</title><link>https://www.infopathdev.com:443/forums/43.aspx</link><description> </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Duplicate "New Record" button Functionality.</title><link>https://www.infopathdev.com:443/forums/thread/49101.aspx</link><pubDate>Mon, 16 Nov 2009 14:26:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:49101</guid><dc:creator>wc19380</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/49101.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=49101</wfw:commentRss><description>OK, 
  I have my proof of concept developed. 
   The code consists of two parts. 
    The &amp;quot;On Load&amp;quot; event will save the XML for reinitialization. 
        The original idea was presented in the below link. Big thanks to the author.
             // reset solution private variable as defined in the below link:
            //http://www.bizsupportonline.net/blog/2009/08/clear-reset-fields-infopath-3-lines-code/
    The &amp;quot;Copy&amp;quot; Button(my custom code), 
      1.) Save a sampling of non key fields from each table.(that&amp;#39;s why this is a proof of concept).
      2.) Replace the Saved &amp;quot;On Load&amp;quot; XML. All the data fields are set back to Blanks. 
      3.) Update the columns from step 1. 
    
Below is the code that supports the proof of concept. 
    The next phase is to eliminate the &amp;quot;On Load&amp;quot; Event code. 
      When the user clicks the &amp;quot;Copy&amp;quot; Button, retrieve the XML. 
       Blank out each of the identity columns.
       Reload the XML back to InfoPath. 


  public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
        //    initialData = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;//my:container&amp;quot;, NamespaceManager).OuterXml;
            initialData = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update&amp;quot;, NamespaceManager).OuterXml;
        }

        public void CTRL114_7_Clicked(object sender, ClickedEventArgs e)
        {
            // Create XPathNavigator positioned at the root of the main data 
            // source.
            XPathNavigator myNav = this.MainDataSource.CreateNavigator();

            // Select employee field and set value to username.
            XPathNavigator nav = MainDataSource.CreateNavigator();


            // save form fields to temporary variables
            string tmpIPD_Description = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/@IPT_Description&amp;quot;, NamespaceManager).ToString();
            string tmpIPT_Lead = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/@IPT_Lead&amp;quot;, NamespaceManager).ToString();
            string tmpSubmission_Date = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Submission_Date&amp;quot;, NamespaceManager).ToString();
              //Clear Key values
            string tmpProject_Status___Duration = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Project_Status___Duration&amp;quot;, NamespaceManager).Value;
            string tmpProject_Status___Effort = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Project_Status___Effort&amp;quot;, NamespaceManager).Value;
            string tmpDays_Ahead_Behind = nav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Days_Ahead_Behind&amp;quot;, NamespaceManager).Value;

            // Retrieve the rows of the TMD_Update child table
            string[] arTask_Status = new string[100];
            string[] arHigh_Level_Description = new string[100];
            string[] ar__Complete = new string[100];
            //Loop through all the TMD rows

            int TMDCount = 0;
            XPathNodeIterator TMD_rows = nav.Select(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/d:TMD_Update&amp;quot;, NamespaceManager);
            while (TMD_rows.MoveNext())
            {

                arTask_Status[TMDCount] = TMD_rows.Current.SelectSingleNode(&amp;quot;@Task_Status&amp;quot;, NamespaceManager).Value;
                arHigh_Level_Description[TMDCount] = TMD_rows.Current.SelectSingleNode(&amp;quot;@High_Level_Description&amp;quot;, NamespaceManager).Value;
                ar__Complete[TMDCount] = TMD_rows.Current.SelectSingleNode(&amp;quot;@__Complete&amp;quot;, NamespaceManager).Value;
                TMDCount = + 1;
            }
            // Retrieve the rows of the AI_Update child table
            string[] arAI_Num = new string[100];
            string[] arAI_Status = new string[100];
            string[] arAI_Description = new string[100];
            string[] arAI_Dependencey_impact = new string[100];
            int AICount = 0;
            XPathNodeIterator AI_rows = nav.Select(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/d:AI_Update&amp;quot;,NamespaceManager);
            // Loop through the rows of the TMD_Update repeating table and initialize key fields to null
            while (AI_rows.MoveNext())
            {
                arAI_Num[AICount] = AI_rows.Current.SelectSingleNode(&amp;quot;@AI_Num&amp;quot;, NamespaceManager).Value;
                arAI_Status[AICount] = AI_rows.Current.SelectSingleNode(&amp;quot;@AI_Status&amp;quot;, NamespaceManager).Value;
                arAI_Description[AICount] = AI_rows.Current.SelectSingleNode(&amp;quot;@AI_Description&amp;quot;, NamespaceManager).Value;
                arAI_Dependencey_impact[AICount] = AI_rows.Current.SelectSingleNode(&amp;quot;@AI_Dependencey_impact&amp;quot;, NamespaceManager).Value;
                AICount = +1;
            }
            // Retrieve the rows of the Mgmt_Attention_Update child table
            string[] arItem_Num = new string[100];
            string[] arDescription = new string[100];
            string[] arProbability = new string[100];
            string[] arImpact = new string[100];
            int MgmtCount = 0;
            XPathNodeIterator Mgmt_rows = nav.Select(
            &amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/d:Mgmt_Attention_Update&amp;quot;,
            NamespaceManager);
            // Loop through the rows of the TMD_Update repeating table and initialize key fields to null
            while (Mgmt_rows.MoveNext())
            {
                arItem_Num[MgmtCount] = Mgmt_rows.Current.SelectSingleNode(&amp;quot;@Item_Num&amp;quot;, NamespaceManager).Value;
                arDescription[MgmtCount] = Mgmt_rows.Current.SelectSingleNode(&amp;quot;@Description&amp;quot;, NamespaceManager).Value;
                arProbability[MgmtCount] = Mgmt_rows.Current.SelectSingleNode(&amp;quot;@Probability&amp;quot;, NamespaceManager).Value;
                arImpact[MgmtCount] = Mgmt_rows.Current.SelectSingleNode(&amp;quot;@Impact&amp;quot;, NamespaceManager).Value;
                MgmtCount = +1;
            }
       
      
            //Clear all data back to the initial state of the &amp;quot;On Load&amp;quot; event
            MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update&amp;quot;, NamespaceManager).ReplaceSelf(initialData);

            // Update form values from saved columns 
             XPathNavigator Upd = MainDataSource.CreateNavigator();
            // Update headerportion(Teams) Key field with blank IPT ID
            Upd.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/@IPT_Description&amp;quot;, NamespaceManager).SetValue(tmpIPD_Description);
            Upd.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/@IPT_Lead&amp;quot;, NamespaceManager).SetValue(tmpIPT_Lead);
            Upd.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Project_Status___Duration&amp;quot;, NamespaceManager).SetValue(tmpProject_Status___Duration);
            Upd.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Project_Status___Effort&amp;quot;, NamespaceManager).SetValue(tmpProject_Status___Effort);
            Upd.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/@Days_Ahead_Behind&amp;quot;, NamespaceManager).SetValue(tmpDays_Ahead_Behind);
            
            //Write back  TMP_Update Section 
            // Loop through the rows of the TMD_Update repeating table and initialize key fields to null
            int x = 0;
            //&amp;#39;get the node you wish to have repeated
            string xpath = &amp;quot;/dfs:myFields/dfs:dataFields/d:Teams/d:CFMS_Update/d:TMD_Update&amp;quot;;
            XPathNavigator uTMD_rows = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
            while (x</description></item><item><title>Re: Duplicate "New Record" button Functionality.</title><link>https://www.infopathdev.com:443/forums/thread/49077.aspx</link><pubDate>Sun, 15 Nov 2009 12:05:24 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:49077</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/49077.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=49077</wfw:commentRss><description>&lt;p&gt;Hi Tom,&lt;/p&gt;
&lt;p&gt;I have no idea. Best practice is to use a Web Service to submit to SQL. If you do that, it&amp;#39;s fairly easy to setup a button to submit duplicates. &lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description></item><item><title>Duplicate "New Record" button Functionality.</title><link>https://www.infopathdev.com:443/forums/thread/48874.aspx</link><pubDate>Tue, 10 Nov 2009 19:11:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48874</guid><dc:creator>wc19380</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48874.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=48874</wfw:commentRss><description>I am trying to execute the same functionality of the &amp;quot;New Record&amp;quot; button. 
    I modified the button to create access key with the button of &amp;quot;ALT-R&amp;quot;
    Then in my code I tried to perform a            
           SendKeys.SendWait(&amp;quot;%(R)&amp;quot;);
     The code doesn&amp;#39;t seem to respond. 
     I can manually press the keys and clear my data. 
     Can anyone tell me what I am doing wrong? 

Thanks in advance.

Regards, 
Tom z.</description></item></channel></rss>