Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

You receive a "Visual Studio must be used to add business logic to this form template" error message when you close the Form Options dialog box in InfoPath


View products that this article applies to.

Symptoms

When you close the Form Options dialog box in Microsoft Office InfoPath 2007 or in Microsoft Office InfoPath 2003, you receive the following error message:
Visual Studio must be used to add business logic to this form template. Please close this form template and open the Visual Studio project for it.
Note If you make changes before you close the Form Options dialog box, the changes are successfully saved even though you receive this error message.

↑ Back to the top


Cause

This problem occurs when you create an InfoPath Form Template project in Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET 2003 and you click to select the Save using custom code check box in the Forms Options dialog box. When you select this check box, Visual Studio 2005 or Visual Studio .NET 2003 adds the OnSaveRequest event handler code to the project. Therefore, when you open the form template file (.xsn) outside Visual Studio 2005 or Visual Studio .NET 2003 in InfoPath, you receive the error message.

↑ Back to the top


Workaround

To work around this problem, make design changes to the form template file (.xsn) only when you work in the InfoPath Form Template project in Visual Studio 2005 or Visual Studio .NET 2003.

↑ Back to the top


More information

For more information about InfoPath development in Visual Studio, visit the following Microsoft Developer Network (MSDN) Web site:

Steps to reproduce the behavior

To reproduce the behavior, follow these steps:
  1. Start Visual Studio 2005 or Visual Studio .NET 2003.
  2. On the File menu, click New, click Project, and then expand Microsoft Office InfoPath Projects.
  3. Click Visual Basic Projects, click InfoPath Form Template, type <InfoPathProjectName> in the Name box, and then click OK.

    Note<InfoPathProjectName> is the name for your InfoPath Form Template project.
  4. In the Microsoft Office Project Wizard, click Create a new form template, and then click Finish.
  5. On the Tools menu, click Form Options, and then click the Open and Save tab.
  6. Click to select the Save using custom code check box, and then click OK.
  7. On the File menu, click Publish, and then click Next two times.
  8. In the Form path and file name box, type <PathandFileName>, and then click Next.

    Note<PathandFileName> is the file name of the form template file (.xsn) and the path where you want to publish the file. For example, type c:\MyForm.xsn.
  9. Click Finish, and then click Close.
  10. On the File menu, click Exit to exit InfoPath.
  11. On the File menu, click Exit to exit Visual Studio 2005 or Visual Studio .NET 2003.
  12. Start InfoPath.
  13. On the File menu, click Open, select the path and file name that you entered in step 8, and then click Open.
  14. On the Tools menu, click Design This Form.
  15. On the Tools menu, click Form Options, and then click OK.
Note After you click OK in the Form Options dialog box, you receive the error message that is mentioned in the "Symptoms" section.

↑ Back to the top


Keywords: KB891160, kbprb, kbbug, kbtshoot, kberrmsg, kbxml, kbdesign, kbprogramming

↑ Back to the top

Article Info
Article ID : 891160
Revision : 5
Created on : 1/30/2007
Published on : 1/30/2007
Exists online : False
Views : 448