472,127 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Saving calculated values

SJH
I have been given an older database and asked to make upgrades and what not.
One interesting thing I have come across with the database is that it was at
one time set up so one of the tables would hold values that were calcuated
using a form. I have looked at the code for all the text boxes on the
assocatied forms and have yet to figure out how this was done. There were
two values set up this way, one still works and the other one doesn't,
needless to say this has turned the reports into a mess.

I know all about manipulating data using queries, but these values are
stored values that will not change once they have been calculated.

Can someone point me in the right direction as to how calcualted values can
be stored in a table? I am not all that familiar with writing code, but I
can usually figure it out once I see it.

Thanks for any help anyone can offer.

SJH


Nov 12 '05 #1
1 2734
"SJH" <12*****@wwt.net(remove first two)> wrote in message news:<7I******************@reggie.win.bright.net>. ..
I have been given an older database and asked to make upgrades and what not.
One interesting thing I have come across with the database is that it was at
one time set up so one of the tables would hold values that were calcuated
using a form. I have looked at the code for all the text boxes on the
assocatied forms and have yet to figure out how this was done. There were
two values set up this way, one still works and the other one doesn't,
needless to say this has turned the reports into a mess.

I know all about manipulating data using queries, but these values are
stored values that will not change once they have been calculated.

Can someone point me in the right direction as to how calcualted values can
be stored in a table? I am not all that familiar with writing code, but I
can usually figure it out once I see it.

Thanks for any help anyone can offer.

SJH

first let me say that I'm not sure storing the calculated values is a
great idea. Just base your report on a query that does the
calculations at runtime.

Okay, that said - there's one way to do it *BEFORE* the record is
saved - just put the code to update the values in the BeforeInsert
event of your form. You could have the calculated fields be invisible
and then do something like:

Me.CalcField1=Expression1(Field1,Field2,Field3)
Me.CalcField2=Expression2(Field3,Field4,Field5)

I don't like this approach at all... what if someone changes any of
the values in fields 1-5? Your calculations go up in smoke. That's
what I really don't like about the scenario you describe. So it takes
a few extra seconds for the report to open... big deal. At least the
data is ALWAYS current if you just base it off a query (or several)
and just calculate everything at runtime.

There. I said it. But I wouldn't do what you're proposing unless you
are absolutely sure you want just "historical"/ReadOnly data after
that. If I were going to do that, then I'd skip the complexity and
just use update/append queries to write the calculated values to a
temporary table, then run my reports and then drop the temp tables.
See Tony Toews site for info on temp tables.
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jeremy Weiss | last post: by
2 posts views Thread by Douglas Buchanan | last post: by
reply views Thread by douh | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.