Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

inserting calculations into a field in forms

Discussion in 'Information Technology' started by Rachel, Jul 28, 2006.

  1. Rachel

    Rachel
    Expand Collapse
    Guest

    Hello. Can anyone help me? In a form that I've made, I have a field where a
    calculation is made from other fields. I want to store the results of this
    calculation back into the table but I don't know how to do it.
    I put the calculation into the 'default value' setting in properties and
    then put the control source as the field where I want it stored, but the form
    field appears blank.

    I'd really appreciate any advice or guidance.

    Thankyou very much,
    Rachel
     
  2. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Default Value is too early. Access processes that before your other fields
    have their values.

    See:
    Calculated fields
    at:
    http://allenbrowne.com/casu-14.html

    The article explains when to store calculated results, how to do so (using
    the AfterUpdate event of each control), and how to have Access give you
    results without storing them when this will have you lots of issues (using
    queries.)

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Rachel" <Rachel@discussions.microsoft.com> wrote in message
    news:08E56E1E-9D68-43AE-9AFD-4A6431C11C00@microsoft.com...
    > Hello. Can anyone help me? In a form that I've made, I have a field where
    > a
    > calculation is made from other fields. I want to store the results of this
    > calculation back into the table but I don't know how to do it.
    > I put the calculation into the 'default value' setting in properties and
    > then put the control source as the field where I want it stored, but the
    > form
    > field appears blank.
    >
    > I'd really appreciate any advice or guidance.
    >
    > Thankyou very much,
    > Rachel
     
  3. Rachel

    Rachel
    Expand Collapse
    Guest

    Thankyou SO much for such a quick and helpful reply. I've been struggling for
    days with this and appreciate your help so much!
    Thanks again,
    Rachel

    "Allen Browne" wrote:

    > Default Value is too early. Access processes that before your other fields
    > have their values.
    >
    > See:
    > Calculated fields
    > at:
    > http://allenbrowne.com/casu-14.html
    >
    > The article explains when to store calculated results, how to do so (using
    > the AfterUpdate event of each control), and how to have Access give you
    > results without storing them when this will have you lots of issues (using
    > queries.)
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "Rachel" <Rachel@discussions.microsoft.com> wrote in message
    > news:08E56E1E-9D68-43AE-9AFD-4A6431C11C00@microsoft.com...
    > > Hello. Can anyone help me? In a form that I've made, I have a field where
    > > a
    > > calculation is made from other fields. I want to store the results of this
    > > calculation back into the table but I don't know how to do it.
    > > I put the calculation into the 'default value' setting in properties and
    > > then put the control source as the field where I want it stored, but the
    > > form
    > > field appears blank.
    > >
    > > I'd really appreciate any advice or guidance.
    > >
    > > Thankyou very much,
    > > Rachel

    >
    >
    >
     
  4. Joseph Meehan

    Joseph Meehan
    Expand Collapse
    Guest

    Rachel wrote:
    > Hello. Can anyone help me? In a form that I've made, I have a field
    > where a calculation is made from other fields. I want to store the
    > results of this calculation back into the table but I don't know how
    > to do it.
    > I put the calculation into the 'default value' setting in properties
    > and then put the control source as the field where I want it stored,
    > but the form field appears blank.
    >
    > I'd really appreciate any advice or guidance.
    >
    > Thankyou very much,
    > Rachel


    Allen properly answered your question about how, but I would suggest
    WHY?

    Generally it is better not to store the results of calculation in a
    table. Access prefers to recalculate them and if you store them and then
    edit one of the sources of the calculation your stored result when then be
    wrong. Consider calculating the age of someone then storing it. On the
    average it will become wrong in 183 days. If recalculated when needed, then
    it will always be correct.

    --
    Joseph Meehan

    Dia duit
     

Share This Page