Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Calculations

Status
Not open for further replies.

mvpdep

Programmer
Nov 11, 2005
21
CA
Hello all I'll try to be as detailed as I can. I have a table 'tbl accounts' that is linked to 'frm1'. The following fields from the table are on 'frm1'.

tblrate1 (1.5%)
tblrate2 (2.25%)
tblrate3 (tblrate1+tblrate2/2) this needs to be calculated
tblratediff (tblrate4-tblrate3) this needs to be calculated
tblrate4 (4.0%)

So ultimately when a person inputs to a new record they would enter 1.5% as the value of 'rate1' and enter 2.25% as the value for 'rate2' and 4.0% for the value of 'rate4'.

Once those values are entered I want calculations to occur for 'tblrate3' which should end up being 1.875% based on the above inputs.

And 'tblratediff' should be 2.125% based on the above inputs.

SO MY QUESTION IS can you have the rates calculated after input and stored in the 'tbl accounts' appropriately and if so HOW?

Or do I need to have the two calculated fields as unbound and then somehow perform a function 'onclick' that then writes the data to the table?

As you can see I'm in a quandry.

PLEASE PLEASE HELP....If you're not sure what I am asking please post for more info and I'll do my best to provide more thanks.

 
There is no need to use unbound fields.

You can make calculations on tblrate3 and tblratediff even if they are bound to respective fields in the table.

You can write the code in the Onclick even of a button or
You can also write the same code in tblrate4_AfterUpdate.

I assume you know how to write the code for calculation.

Regards,
 
Thank you for your input so what you are recommending is that in tblrate2 I write code to calculate tblrate3 (afterupdate)

And then in tblrate4 I write code to calculate tblratediff (afterupdate)

If the answer is yes is it correct of me to assume the code would look something like the following:

me.tblratediff=[forms]![frm 1]![tblrate4-tblrate3]

Would that be correct thanks.
 
Yes You are correct.
It should work fine.

You can place this line of code
me.tblratediff=[forms]![frm 1]![tblrate4-tblrate3]
in tblrate4_AfterUpdate event.

Just test it and let me know how it goes...

Make sure you check and trap for blank/null field values
i.e., trap the fields for which users have not entered any data. Either set the default value to 0 or assin it via Code.

Regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top