Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

Repeating sections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 15 Mar 2006 23:17 GMT
Is there a way to stop the user from removing all of the repeating sections?
Andrew - 15 Mar 2006 23:39 GMT
Is there a way to do this either through code or some how setting the minimum
occurrences to 1 instead of 0

Thanks,
 Andrew
Bojana Marjanovic [MSFT] - 16 Mar 2006 03:56 GMT
Two ways I can think of to accomplish this:

1. When working on your form template, you can save it as Source Files (from
the File menu). You can then open the myschema.xsd file and adjust the min
occurs value for your particular element. This will be respected in InfoPath
and an error will appear if a user tries to delete the last item.
Unfortunately, this method does come with a somewhat unattractive error
message.

2. Use the onBeforeChange/Changing event to check if this is the last
instance of that particular section. If it is, you can programmatically
prevent the change and display a dialog with an error message.
Here's an example:
public void repeatingTable_OnBeforeChange(DataDOMEvent e)

{

   //check for a delete operation

   if (e.Operation == "Delete")

   { IXMLDOMNode table = e.Site;

    //check to see if this is the last row

       if (table.firstChild.nextSibling == null ||
table.firstChild.nextSibling.nodeName == "#text")

       { e.ReturnMessage = "You must include at least one row in this
table.";

          e.ReturnStatus = false;

       }

   }

}

Let me know if this helps,
Bojana

> Is there a way to do this either through code or some how setting the
> minimum
> occurrences to 1 instead of 0
>
> Thanks,
>  Andrew
Andrew - 16 Mar 2006 15:38 GMT
Since I have c# code behind the form I went ahead and used a variation of
your second suggestion.

IXMLDOMNodeList NodeLst = e.Source.selectNodes("/my:myFields/my:LI_PO");

if ( NodeLst.length == 0)
  {
     e.ReturnMessage = "You must include at least one Line Item.";
     e.ReturnStatus = false;
  }

Thanks,

 Andrew

> Two ways I can think of to accomplish this:
>
[quoted text clipped - 44 lines]
> > Thanks,
> >  Andrew
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.