The information in this article applies to:
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
MORE INFORMATION
NOTE: In Microsoft Access 7.0 and 97, the "Form" or "Report" identifier is
optional when referring to control properties. It is necessary, however,
when referring to subform or subreport properties.
To refer to a control on a subreport, use the following syntax:
NOTE: Only subforms are discussed in the rest of this article, but all the information applies to both subforms and subreports. It is important to note that you cannot refer to controls on a subform with the following syntax:
This is because a subform on a main form is not a form, but is a control just like a text box or a list box. You must refer to a subform as a control rather than a form, and specify the Form identifier following the subform control name reference to gain access to the controls on a subform. It is also important to note that when you are referring to controls on a subform, you must specify the value contained in the ControlName property of the subform control. The ControlName property should not be confused with the SourceObject property for a subform control. The SourceObject property is used to indicate which subform to use in the subform control. The ControlName property is used to specify the name by which the subform control is referenced. ControlName is typically set the same as the SourceObject, but it does not have to be. For example, consider an Order Details subform on an Orders form with the following properties:
You can refer to a Unit Price control on the Order Details subform with the following reference:
If, however, the subform control has the following properties
you must refer to the Unit Price control on the Order Details subform with this reference:
Examples of Referencing Controls on a SubformYou could use the following SetValue macro action to increase the Unit Price value on the Orders Subform by 10 percent:
If the macro is attached to a button on the Orders form, you can use this expression for the SetValue Expression argument:
If you are referring to a control on a subform from another control on the same subform, you do not have to enter the Form property identifier. For example, to refer to the Unit Price value on the Order Details subform in a macro attached to a button on the Order Details subform, you can enter:
The following expression can be entered as the ControlSource property for the Subtotal control on the Orders main form to display a value calculated in the hidden Order Subtotal control on the Order Details subform:
To refer to the value of a control on the parent (main) form from a control on a subform, use the Parent property. For example, the following expression entered in a control on a subform refers to the Customer ID field on the parent form.
To refer to a control on a nested subform (a subform on a subform), you can use the following syntax:
Common Problems Encountered When Referencing Subform Controls
REFERENCESFor more information about controls, type "controls" in the Office Assistant, click Search, and then click to view "Controls: What they are and how they work."
Keywords : FmsSubf RptSub |
Last Reviewed: April 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |