Calculations Part A

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

Guest

I am looking to write some code, that could do calculations in my table so
that I can have retained values as well as fewer manual key strokes and less
chance for error through data entry.

Basically I need a formula that occurs as follows, but I am unsure if I
have the syntax correct:

If [d] is "y" then (([f]/120)*120) but if [d] is "n" then (([f]/60)*120)
entering the product into .

eg:

d= y
[f]
((240/120)*120) = 240

d = n
[f]
((180/60)*120) = 360
 
Tara, are there any cases where your field i should *not* be the same as the
calculation?

- Yes: there are cases where it could be different.
Use the AfterUpdate event of d and f to assign a value to i.

- No: it should never be different.
Don't store the value. Instead, create query that calculates i.

Details of both approahes in this article:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

BTW, the calculated field in the query would be just:
i: IIf([d] = 'y', [f], [f] / 2)
or (if d is a yes/no field):
i: IIf([d] = True, [f], [f] / 2)
 
I am looking to write some code, that could do calculations in my table so
that I can have retained values as well as fewer manual key strokes and less
chance for error through data entry.

Basically I need a formula that occurs as follows, but I am unsure if I
have the syntax correct:

If [d] is "y" then (([f]/120)*120) but if [d] is "n" then (([f]/60)*120)
entering the product into .

eg:

d= y
[f]
((240/120)*120) = 240

d = n
[f]
((180/60)*120) = 360



Never put calculations in a table (not even sure that you can). Never
allow users to edit data directly in a table.
Use forms or queries to do this. The best answer will depend on where
that will be and the events that trigger it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top