Sunday, September 10, 2017

Create a control that references a control on another form

Create a control that references a control on another form

This article describes you how to add a text box control to a form, and then set the properties for that text box so that it displays a value from a control on another form. This is useful in the following situations:

  • You have a main form that contains a subform; the subform contains a calculated text box (for example, a total of item prices), the results of which you want to display on the main form.

  • You have a form that contains a command button that opens a second form, and you want a text box on the second form to display the value of a control on the first form.

Create the control

  1. In the Navigation Pane, right-click the form that you want to change, and then click Layout View.

  2. On the Design tab, in the Controls gallery, click Text Box.

  3. Click in the form where you want to create the text box.

  4. Make sure that only the text box is selected. If necessary, click a different control, and then click the text box again.

  5. If the property sheet is not already displayed, right-click the text box and then click Properties.

  6. In the Property Sheet task pane, click the All tab.

  7. Set the Control Source property using the following syntax:

    =[ Forms]![ form name ]![ control name ]

    Where form name is the name of the form that contains the control whose value you want to display, and control name is the name of the control.

Example

Suppose that you have a main form named Orders. This form contains a subform named Orders Subform, and the subform contains a calculated text box named OrderSubtotal. To display the value from the OrderSubtotal control on the Orders main form, you would add a text box to the Orders main form and specify its Control Source property as follows:

=[ Forms]![Orders Subform]![ OrderSubtotal ]

Top of the Document

No comments:

Post a Comment