I have a form with 2 fields. I use the first field to enter a number and if I enter this number, it saves me the number into the related field in the table. This works good. But in the second field I created a formula for this field, to count the number. It is using the number from the first field and multiplies it with another number. It works well because I can see the right number, but it is not saving that calculated number to the related field in the table.
Not able to save data from a field in a form to a table.
Collapse
X
-
Welcome to Bytes :)Hi Guys.
I got a problem.
I have a form with 2 fields. I use the first field to enter a number and if I enter this number, it saves me the number into the related field in the table. This works good. But in the second field I created a formula for this field, to count the number. It is using the number from the first field and multiplies it with another number. It works well because I can see the right number, but it is not saving that calculated number to the related field in the table.
Can you help me with that please.
Thanks
Is there any particular need to table store a calculated value?
I am not saying do NOT do it but generally you should not need to. My guess is that you do not know that a form can be based on a query.
Look at Access Help - 'Ways to perform calculation in a query' it is all documented
you will then understand that query can contain a 'formula' as an expression the advantages to you being that it becomes a usuable column in your dataset underlying the form. You only need bind the controlsource of the textbox to the column.
To help you I have attached a simple db take a lookAttached Files -
My guess is that you have the formula in the Control Source of the wayward control, While this will display the calculation in the control, a control can only have one Control Source, hence it cannot be bound to the field in the underlying table.
To do this as you're asking you need to- Change the Control Source of the 2nd control to the field in the underlying table
- Place your calculation in the AfterUpdate event of the first control, assigning it to the 2nd control (Me.SecondContro lName = [Your calculation goes here])
Having said that, it is very seldom that calculations should be stored in tables! Instead, the calculation should simply be recalculated anytime you need it, whether in a form or a report.
Welcome to Bytes!
Linq ;0)>
Addendum: Jim's approach is also valid! In point of fact, I always base forms on queries, even if only one table is involved, for just the reason he gave.Comment
-
-
Alright so I am back once again:) Maybe its just me that I am dumb and not really skilled with access, but I tried to do it the way that I should set the after update field with the expression you wrote me(ofcourse I changed the names:)), but it keeps writing me out this: Microsoft office access can't find the macro `Me.`
Can you please explain it once again to me how should I change the first field to update the second one with the calculations.
Thanks a lot guysComment
-
Comment
Comment