We recommend using Visual Studio 2017

FormErrorCollection.GetErrors Method (String) (Microsoft.Office.InfoPath)

Returns all FormError objects of the specified name from the FormErrorCollection object associated with the current form.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

public abstract FormError[] GetErrors (
	string name



The name of the errors to return.

Return Value

An array of type FormError that contains all errors of type FormErrorType.UserDefined with the specified name.

Exception typeCondition


The parameter passed to this method is null.


The parameter passed to this method isnot valid. For example, it is of the wrong type or format.

An empty array is returned if there are no errors in the collection of the specified name.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft Office InfoPath 2007 or in a Web browser.

In the following example, the GetErrors method of the FormErrorCollection class is used to get all errors named DateFormatError from the form's errors collection. The Message property of the FormError class is then used to display their error messages.

FormError[] myErrors;
myErrors = this.Errors.GetErrors("DateFormatError");

foreach(FormError err in myErrors)