Subscribe to Windows IT Pro
October 30, 2007 09:09 PM

Add a calculated column

Windows IT Pro
InstantDoc ID #104328
Rating: (0)

A calculated column adds a column to the dataset that contains the results of an expression. It does not simply aggregate data in one field—it creates a new ‘field’ in the dynaset.

  • Click in a blank Field cell of the QBE grid and create a calculated column by typing: ColumnName:expression. That is, you decide what name you want the column to appear as in the dynaset, type that name followed by a colon and follow the colon with the mathematical expression.

A typical example, used in creating a dynaset for inventory control, would be a calculated column: Inventory Value:[UnitsInStock]*[UnitPrice]. UnitsInStock and UnitPrice are fields in an inventory table—remember that field names used in expressions must be surrounded by square brackets. The inventory value is not stored in the table, because it doesn’t have to be. It can always be calculated, so to save space, improve performance, and discourage errors in data entry, a query is used to produce an inventory report. On that query’s dynaset, a column will appear with the correct, current inventory value.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.