Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / February 2007

Tip: Looking for answers? Try searching our database.

Store a text box calc value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FL - 27 Feb 2007 00:29 GMT
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.
Signature

FL

Damian S - 27 Feb 2007 00:45 GMT
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.

> 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.
John W. Vinson - 27 Feb 2007 06:44 GMT
>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]
FL - 27 Feb 2007 21:59 GMT
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.

Signature

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
[quoted text clipped - 25 lines]
>
>              John W. Vinson [MVP]
John W. Vinson - 28 Feb 2007 07:04 GMT
>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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.