Consulting

Results 1 to 4 of 4

Thread: My expression on a form won't save to the table

  1. #1

    My expression on a form won't save to the table

    Hey, I have an expression that calculates the 'change' a customer is due based on deducting the item price from the amount tendered;

    =[Amount Taken]-[Price]

    (this is the control source for my text box). The box successfully calculates and displays the amount of change the customer should receive, yet the value does not get saved as a record in my table.

    Does anyone know some code/expression that will save this particular value to the table, (afterupdate maybe)? I have tried DoCmd.Save to no avail.

    Thank you for reading

  2. #2
    VBAX Regular
    Joined
    Jan 2007
    Posts
    20
    Location
    You shouldn't store the results of a calculation in a table. If you need to know the change due at a later time you can just query it out.

    hth,
    Giacomo

  3. #3
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    Hi,

    When you do an automatic calculation, such as yours, Access, to the best of my knowledge does not save the results to the table. It will still be saved in the form, if you are creasting a new record each time you use it. I haven't found a way around this, but maybe some of the super minds on this forum have.

    Good Luck

    Gary

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,297
    Location
    The reason that Access can't save it to the table is because the Record source is the function instead of the table.
    As omocaig says you should not really store the results of calculations in a table, unless it makes some other "difficult" calculation easier by doing so, like using Cross Tab or Grouping Queries or Graphs.
    So if the data must be saved, to overcome the problem, use a Function in a Query or some VBA to do the calculation instead of a function in the form.

Posting Permissions

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