Results 1 to 5 of 5
  1. #1
    wubbo38
    Guest

    change in calculated control (A97 SR2)

    How do I put the value from a calculated control (based on a subform) into a table (the main form is based on this table) when it changes? Which event do I use? (I know "Change", "after update" and "before update" don't occur when a value changes in a calculated control. )
    I tried the "on exit" event on the subform but this did not work!!! <img src=/S/hello.gif border=0 alt=hello width=25 height=29>

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: change in calculated control (A97 SR2)

    It isn't generally a good idea to store calculated values. It's difficult to make sure they are kept up to date, and they can always be calculated when they are actually needed. If you actually wanted to store the calculated value, you would either have to do it with a recordset or by running an update query from code. There is not way to bind a calculated field.
    Charlotte

  3. #3
    wubbo38
    Guest

    Re: change in calculated control (A97 SR2)

    thanks for the reply Charlotte but....
    the problem is the calculated control is based on costs and although it is calculated correctly now, down the track when costs change the calculated control will show an incorrect value for the old records. Also the user wants the ability to edit the figure.
    I have tried to use 2 text boxes - a hidden one with the calculated control and a bound textbox with the hidden text boxes value.The problem is setting the value of the TextBox equal to the value of the calculated control from the subform
    <img src=/S/drop.gif border=0 alt=drop width=23 height=23>

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: change in calculated control (A97 SR2)

    <hr>down the track when costs change the calculated control will show an incorrect value for the old records<hr>
    Excuse me? That's exact;y why you *don't* store calculated values. Furthermore, you simply cannot edit a calculated control, and even if you could, it would negate the whole point of a calculated value--that it is calculated automatically.

    Users often want to do things that are a bad idea or simply impossible. That's when a developer's diplomatic skills come into use. I usually explain the kind of problem they're building for themselves in painful detail and then try to find an acceptable alternative based on why they thought they should do that.
    Charlotte

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change in calculated control (A97 SR2)

    Hmm... I think I interpreted your "down the track when costs change..." phrase exactly the opposite from how Charlotte interpreted it! <img src=/S/confused.gif border=0 alt=confused width=15 height=20> I think I see what you're getting at.

    Do you need a calculated control? Can you not simply compute the value of your bound textbox in code? There's a few places you could do it - in the OnInsert event if you want the calculation to only be done for new records; in the afterupdate events of whatever is used to calculate your field; or in the beforeupdate event of the form (I don't recommend the latter because the user won't see the calculations until he leaves the record and comes back to it).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •