Store a text box calc value

F

FL

I'm trying to store/display a text box calc value/result (calc is located in
control source property line) into another text box numeric field (control
source is a field name). The value to store is in this format 00:00. I use
a set value in macro to assign this value to this numeric field. But it does
not work. My numberic field has to be numberic because I will need to sum
and average the results of many records.
 
D

Damian S

Hi FL,

As a general rule, you NEVER want to store a value that you can calculate.
What specifically are you trying to achieve?

Damian.
 
J

John W. Vinson

I'm trying to store/display a text box calc value/result (calc is located in
control source property line) into another text box numeric field (control
source is a field name). The value to store is in this format 00:00. I use
a set value in macro to assign this value to this numeric field. But it does
not work. My numberic field has to be numberic because I will need to sum
and average the results of many records.

Well, a couple of problems here.

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.

Secondly, 00:00 looks like a time format; it is certainly NOT a number
format, and you will not be able to do sums or averages on it.

Could you explain the nature of the calculation, the datatype and
nature of the result, and why you feel that it must be stored rather
than recalculated as needed?

John W. Vinson [MVP]
 
F

FL

Hi John,

Here's what I'm trying to do.

Records (example):
Field Name - Time Duration
Record - 3hrs 32 minutes shown as 03:32
Record - 4hrs 10 minutes shown as 04:10
Record - 2hrs 25 minutes shown as 02:25

I need to store many of these records then do an average on a huge list of
times (not clock time) but, a time duration. This is why I need to store in
a numberic field and not a time/date field. How can I do this? Any
suggestions? Maybe my format of 00:00 cannot be used for this purpose.
 
J

John W. Vinson

I need to store many of these records then do an average on a huge list of
times (not clock time) but, a time duration. This is why I need to store in
a numberic field and not a time/date field. How can I do this? Any
suggestions? Maybe my format of 00:00 cannot be used for this purpose.

It cannot.

Store the minutes in a Long Integer. 3:30 should be stored as 210.

You can *display* it as hours:minutes with an expression like

[Duration] \ 60 & Format([Duration] MOD 60, "\:00")

John W. Vinson [MVP]
 

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