Form Data - Back to Table For Storage - PLEASE HELP

G

Guest

Thanks in advance for any help. I have a form where a field (which is a field in a table) where I want to remove the control source (which was the field name from the table) and use an expression to say = (field name from another subform built from cross tab query). Problem is the field now gets the right value for form view, but the info is not stored in the table where I need it to later pull reports. If it was to just data entry, it works, if it was just for form view, it works, but I need that field to equal a calculated number and be stored in the matching field in the table. PLEASE HELP IF AT ALL POSSIBLE.
 
J

John Vinson

Thanks in advance for any help. I have a form where a field (which is a field in a table) where I want to remove the control source (which was the field name from the table) and use an expression to say = (field name from another subform built from cross tab query). Problem is the field now gets the right value for form view, but the info is not stored in the table where I need it to later pull reports. If it was to just data entry, it works, if it was just for form view, it works, but I need that field to equal a calculated number and be stored in the matching field in the table. PLEASE HELP IF AT ALL POSSIBLE.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.
 
J

John Vinson

John, thanks for the response, I need the data stored because it is used later to build a report.

That would be true IF you had to have data in a table in order to
report it. YOU DON'T. If you can do the calculation on a Form you can
do the calculation in a QUERY, and base your report on that query; or,
you can do the calculation on the Report in precisely the same manner
that you did on the form.
I also tried using a setvalue macro to get the info from the field instead of using the control source. I am unable to get that to work - I believe I may not be able to set values from one subform to another? My biggest concern is that I need to print a report that would supply this information and you can't build reports from anything but tables or queries and if the info isn't there, then I can't report it? Is there a way to get it into the table?

Your assumption about reports IS COMPLETELY INCORRECT. It's a common
assumption, but it's still wrong.

Yes, you must base a Report on a Query; *but* you can a) put
calculated fields in that query or b) set the Control Source of report
controls to an expression, exactly as you can do on a Form.

If you INSIST on storing the data in a table (and there are good
reasons to do so, though needing to report that expression is *not*
one of those good reasons), you can use VBA code in the Form's
BeforeUpdate event. Set the values of bound controls to the calculated
field values:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Me!txtBoundPrice = Me!txtCalcPrice
<etc>
 
G

Guest

Your awesome - I prety much came to the same conclusion last night that I can just recalculate again in the report or do a query
 

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

Similar Threads


Top