Design a read-only view

In Microsoft Office InfoPath, you can create different views of the same form template. A view is an alternative way to present data in a form template. When filling out forms based on your form template, users can switch between views to choose the amount of data that is shown in the form. For example, in a status report form template, you might design a summary view in addition to a detailed view. Users can then choose which view they want to look at, depending on what type of information they need.

This article explains how to design a view that cannot be edited by users. It also explains how to use rules to automatically switch to a read-only view of a form when a user clicks a button in the read-write view.

What do you want to do?

Design a read-only view

Insert a button that switches between a read-write and read-only view

Insert a button that switches to the read-only view after users submit the form

Design a read-only view

Read-only views are useful when you want to summarize form data for users, and you don't want them to inadvertently change that data. For example, suppose that you want to help prevent users from changing the data in a form after they submit it to a Web service. When a user clicks a Submit button on the form, you can configure your form template to switch from a read-write view of the data to a read-only view. This allows users to see what data they have submitted, but helps prevents them from modifying it.

  1. On the View menu, click Manage Views.

  2. Under Actions, click Add a New View.

  3. In the Add View dialog box, type a name for the view, and then click OK.

  4. Design the view by adding layout tables and controls to it.

    Tip: If you want to base the design of a new view on an existing view, open the existing view, press CTRL+A to select everything in the view, and then press CTRL+C to copy the selection to the Clipboard. In the Views task pane, switch to the new view, and then press CTRL+V to paste the selection in the new view. At this point, you can delete any controls or layout elements that you don't need from the new view.

  5. In the Views task pane, click View Properties.

  6. Click the General tab.

  7. Under View settings, select the Read-only check box, and then click OK.

  8. To test that the view is read-only, click Preview on the Standard toolbar.

  9. In the Preview window, ensure that you cannot enter data in the form.

  10. To return to design mode, click Close Preview on the Standard toolbar.

Top of Page

Insert a button that switches between a read-write and read-only view

Views are often designed to work with buttons and rules, which allows you to automate certain tasks in a form template in response to events or actions initiated by the person filling out the form. For example, you can insert a button on your form template, and then create a rule that switches views when that button is clicked. In the following example, the form designer has created a rule in the Rule dialog box that switches to a read-only summary view. This rule runs whenever users click a button in the form.

Part of the Rule dialog box

Insert a button that switches between views

  1. On the View menu, click Manage Views.

  2. Under Select a view, click the read-write view that you want to add a button to.

  3. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  4. On the form template, place your cursor where you want to insert the button.

  5. Under Insert controls, click Button.

  6. On the form template, double-click the button that you just inserted.

  7. Click the General tab.

  8. In the Action list, click Rules and Custom Code.

  9. In the Label box, type the text that you want to appear on the button.

  10. Click Rules.

  11. In the Rules dialog box, click Add.

  12. In the Name box, type a name for the rule.

  13. Click Add Action.

  14. In the Action list, click Switch views.

  15. In the View list, click the view that you want to switch to, and then click OK.

  16. Click OK to close all of the open dialog boxes.

  17. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

  18. In the Preview window, click the button.

    The view that you specified in step 15 should open.

  19. To return to design mode, click Close Preview on the Standard toolbar.

  20. To add a second button and rule to the read-only view so that users can switch back to the read-write view, open the read-only view, and then repeat steps 3 through 19.

Top of Page

Insert a button that switches to the read-only view after users submit the form

The following procedure describes how to add a button to your form template that displays a read-only view of submitted data. You might do this in a status report form, when you want to allow users to switch from a default view to a read-only summary view of the form data.

Note: This procedure works only if your form template includes an existing data connection for submitting form data. If you haven't yet configured a submit data connection, you must do so before completing this procedure, or the following steps won't work. Find links to more information about data connections in the See Also section.

  1. On the View menu, click Manage Views.

  2. Under Select a view, click the view that you want to contain the Submit button.

  3. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  4. On the form template, place your cursor where you want to insert the button.

  5. Under Insert controls, click Button.

  6. On the form template, double-click the button that you just inserted.

  7. Click the General tab.

  8. In the Action list, click Submit.

  9. If you want text other than "Submit" to appear as the button label, type the text that you want in the Label box.

  10. Click Submit Options.

  11. In the Submit Options dialog box, make sure that the Allow users to submit this form check box is selected.

  12. Click Perform custom action using Rules, and then click Rules.

  13. In the Rules for Submitting Forms dialog box, click Add.

  14. In the Name box, type a name for the rule, and then click Add Action.

  15. In the Action list, click Switch views.

  16. In the View list, click the read-only view that you want to switch to, and then click OK.

  17. Click OK to close all of the open dialog boxes.

  18. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

  19. In the Preview window, click the button used for submitting the form.

    The read-only view should open.

  20. To return to design mode, click Close Preview on the Standard toolbar.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×