开发者

ms-access calculated controls

can someone give me an example of what a calculated control is in ms-a开发者_运维技巧ccess?


Say you add a text box to a form, normally it binds back to a specific field in a table, and its contents reflect the contents of that field. A calculated control does not refer to a specific field in a table, rather it displays the calculation done on one or multiple fields in the database. Sometimes, it may not use any fields.

Example of control source value from a calculated control

=[YearlySalary]/52

Presuming that there is a field called yearly salary in the table the form is based on.

A control that simply displays this field would have the following in the control source

YearlySalary

Note the control source for a calculated control starts with an =


you mean this?


Setting the Control Source of a control, generally a textbox, to a calculation creates a calculated control:

=1 * 2
=[TheDate] - 1
=[Stock] * [UnitPrice]
=DlookUp("TheField","TheTable","FieldX=1")


Different cases:

  1. Text box control: here you may be using a trim("text") function to remove spaces and clean up the data--that process requires some calculation

  2. List box control: a calculation may be involved in the query that comprises it's row source. The calculation could be the combination of some kind of cyclic function on a numeric field value which then dramatically changes the order of the data if so directed.

  3. Command Button: a variable could change with the number of presses which in turn changes the command mode of the button. Could change the color of the button, or could hide the button after a certain number of clicks, or could change the column of the listbox that is sorted in a query--each click advances the sort to the adjacent column to the right.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜