Figure 1 (above): This is the property sheet for a Calculated Control. The CONTROL SOURCE is located on the top line of the DATA TAB. |
Figure 3: The Calculated Text Box Control multiplies the UnitCost by Quantity to produce a Total. |
The procedure for setting up a Calculated Control such as this is really quite easy. It is useful, however, to have some knowledge of creating and modifying forms in DESIGN VIEW. This is how I created the Calculated Text Box Control:
- I began with an existing form called frmOrderDetails. The form was bound to a table called tblOrderDetails. The form began with 4 text box's displaying the ProductId, OrderId, UnitCost, and Quantity fields.
- The form was opened in DESIGN VIEW. This was done by right-clicking the frmOrderDetails form, and selecting the Design View Icon from the drop down menu which opened.
- An unbound Text box Control was added by clicking the TEXT BOX icon and positioning the control on the form design grid. The TEXT BOX Icon is located on the CONTROLS group of the DESIGN ribbon. I had to make sure the USE CONTROL WIZARDS icon was not highlighted before doing so.
- I then highlighted the new unbound Text Box Control and clicked the PROPERTY SHEET icon on the TOOLS group of the DESIGN RIBBON.
- I needed to select the DATA tab on the newly opened PROPERTY SHEET.
- I then entered the expression =[unitcost]*[quantity] into the CONTROL SOURCE property. Unitcost was a reference to the bound UnitCost text box, and Quantity was a reference to the bound Quanty text box. These were the expression's Identifiers, and the * symbol was it's multiplication operator. NB I could have typed this expression directly into the text box on the DESIGN GRID - it would have set the CONTROL SOURCE property without having to open the PROPERTY SHEET.
- Then when I opened the form and entered values in the two bound fields of UnitCost and Quantity, the Total Amount appeared automatically in the calculated text box control.
No comments:
Post a Comment