Calculating Fields - Control Source Code Error?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two number fields I'd like to multiply in a form
T
H

The calculation will be stored in the number field
UnitLoa

In the UnitLoad Control Source I have the code
=[UnitLoad]=[Ti]*[Hi

When I close Design Mode "#Error" appears in the UnitLoad field. What have I done wrong

Thanks
 
You cannot have both calcuation and also the name of the field to write the
result to, all in the one Control Source.

It is possible to use the AfterUpdate event of Ti and Hi to write to
UnitLoad. Before you do that, you should be aware that doing so breaks
fundamental rules of data design. Unless there is a valid reason why
UnitLoad should not equal the product of Ti and Hi, you should not store
this result.

For details, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnLute said:
I have two number fields I'd like to multiply in a form:
Ti
Hi

The calculation will be stored in the number field:
UnitLoad

In the UnitLoad Control Source I have the code:
=[UnitLoad]=[Ti]*[Hi]

When I close Design Mode "#Error" appears in the UnitLoad field. What have
I done wrong?
 
I checked out the link and am still a little confused

So, how do you get the calculated field if you do not store it in a table? Use a query

Create a query into your table.
Type your expression into the Field row of the query design grid
Amount: [Quantity] * [UnitPrice]
This creates a field named Amount. Any form or report based on this query treats the calculated field like any other, so you can easily sum the results. It is simple, efficient, and foolproof

So mine would look like this
Amount: [Ti] * [Hi



----- Allen Browne wrote: ----

You cannot have both calcuation and also the name of the field to write th
result to, all in the one Control Source

It is possible to use the AfterUpdate event of Ti and Hi to write t
UnitLoad. Before you do that, you should be aware that doing so break
fundamental rules of data design. Unless there is a valid reason wh
UnitLoad should not equal the product of Ti and Hi, you should not stor
this result

For details, see
Calculated field
at
http://allenbrowne.com/casu-14.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.htm
Reply to group, rather than allenbrowne at mvps dot org

JohnLute said:
I have two number fields I'd like to multiply in a form
T
H
The calculation will be stored in the number field UnitLoa
In the UnitLoad Control Source I have the code =[UnitLoad]=[Ti]*[Hi
When I close Design Mode "#Error" appears in the UnitLoad field. What hav
I done wrong
 
Yes. Just type that expression directly into the Field row of the query
design grid.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnLute said:
I checked out the link and am still a little confused:

So, how do you get the calculated field if you do not store it in a table? Use a query:

Create a query into your table.
Type your expression into the Field row of the query design grid:
Amount: [Quantity] * [UnitPrice]
This creates a field named Amount. Any form or report based on this query
treats the calculated field like any other, so you can easily sum the
results. It is simple, efficient, and foolproof.
So mine would look like this:
Amount: [Ti] * [Hi]

?

----- Allen Browne wrote: -----

You cannot have both calcuation and also the name of the field to write the
result to, all in the one Control Source.

It is possible to use the AfterUpdate event of Ti and Hi to write to
UnitLoad. Before you do that, you should be aware that doing so breaks
fundamental rules of data design. Unless there is a valid reason why
UnitLoad should not equal the product of Ti and Hi, you should not store
this result.

For details, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

JohnLute said:
I have two number fields I'd like to multiply in a form:
Ti
Hi
The calculation will be stored in the number field: UnitLoad
In the UnitLoad Control Source I have the code: =[UnitLoad]=[Ti]*[Hi]
When I close Design Mode "#Error" appears in the UnitLoad field.
What have
I done wrong?
 
Back
Top