Assign value to field in table through form

A

Andreas

I have a form inside which several complex calculations are executed
according to user input and selections. A few text-boxes at the end contain
the final results which I want to store in my table's fields. However, those
textboxes have as control source values like:
=[Text49]-[Text61]

How can I assign those final results to specific fields of my table?
 
D

Douglas J. Steele

Calculations shouldn't be stored in tables.

As fellow Access MVP John Vinson likes to say "Storing calculated data
generally accomplishes only three things: it wastes disk space, it wastes
time (a disk fetch is much slower than almost any reasonable calculation),
and it risks data validity, since once it's stored in a table either the
Total or one of the fields that goes into the total may be changed, making
the value WRONG."

If it's essential to you that you store the values, you'll have to put code
in the form's BeforeUpdate event to transfer the value from the control to
the appropriate field in the recordset.
 
A

Andreas

What do you suggest for the case where you have a form with several options
according to which you make some calculations and then you need to use those
results in a printed report. Do I have to repeat the same logic and formulas
in the report? That could be very hard because I may have several reports
with based on the same results which are complicated to calculate

Douglas J. Steele said:
Calculations shouldn't be stored in tables.

As fellow Access MVP John Vinson likes to say "Storing calculated data
generally accomplishes only three things: it wastes disk space, it wastes
time (a disk fetch is much slower than almost any reasonable calculation),
and it risks data validity, since once it's stored in a table either the
Total or one of the fields that goes into the total may be changed, making
the value WRONG."

If it's essential to you that you store the values, you'll have to put
code in the form's BeforeUpdate event to transfer the value from the
control to the appropriate field in the recordset.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Andreas said:
I have a form inside which several complex calculations are executed
according to user input and selections. A few text-boxes at the end
contain the final results which I want to store in my table's fields.
However, those textboxes have as control source values like:
=[Text49]-[Text61]

How can I assign those final results to specific fields of my table?
 
D

Douglas J. Steele

My recommendation would be to have a function that returns the value, given
the appropriate input parameters.

Use that function on both your forms and reports.

However, as I implied, there are some times when it might make sense to
store the results of calculations in the table, and I did tell you how.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Andreas said:
What do you suggest for the case where you have a form with several
options according to which you make some calculations and then you need to
use those results in a printed report. Do I have to repeat the same logic
and formulas in the report? That could be very hard because I may have
several reports with based on the same results which are complicated to
calculate

Douglas J. Steele said:
Calculations shouldn't be stored in tables.

As fellow Access MVP John Vinson likes to say "Storing calculated data
generally accomplishes only three things: it wastes disk space, it wastes
time (a disk fetch is much slower than almost any reasonable
calculation), and it risks data validity, since once it's stored in a
table either the Total or one of the fields that goes into the total may
be changed, making the value WRONG."

If it's essential to you that you store the values, you'll have to put
code in the form's BeforeUpdate event to transfer the value from the
control to the appropriate field in the recordset.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Andreas said:
I have a form inside which several complex calculations are executed
according to user input and selections. A few text-boxes at the end
contain the final results which I want to store in my table's fields.
However, those textboxes have as control source values like:
=[Text49]-[Text61]

How can I assign those final results to specific fields of my table?
 

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

Top