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