The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). SUMMARYThis article describes the ControlSource property and demonstrates how you can use the SetValue macro action to store calculated values in the underlying table of a control. MORE INFORMATION
A control can be classified as bound, unbound, or calculated, depending on
the contents of its ControlSource property.
The control displays the data from the LastName field, and stores any
changes that you make in the control to the LastName field in the underlying table of the form.
An unbound control has a ControlSource property that is blank. This means that the control is not connected to a field from an underlying table, a query, or an expression. An unbound control can display data, but it cannot save data. The data contained in an unbound control is temporary; it is lost when you close the form or the report. A calculated control displays a value derived from data in one or more fields from the underlying table or query or from other controls. The calculation is the result of an expression assigned to the ControlSource property for that control. A calculated control can display data that is the result of an expression, but it cannot save data. For example, the following control is a calculated control:
The MyControl control displays a full name derived from an expression
concatenating the last name and first name. The full name is not stored in
any table. Calculated controls are often used on a form to display calculations that do not need to be stored in the underlying table.
Storing Calculations in a FieldIf you want to store calculated values in the underlying table of a control, use the SetValue macro action, as demonstrated in the following example.CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
REFERENCESFor more information about creating calculated controls, click Microsoft Access Help on the
Help menu, type calculated control in the Office Assistant or the Answer Wizard,
and then click Search to view the topic. Additional query words: inf
Keywords : kbdta FmsHowto |
Last Reviewed: July 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |