By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,148 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Not able to save data from a field in a form to a table.

P: 3
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.
Apr 29 '10 #1

✓ answered by missinglinq

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
  1. Change the Control Source of the 2nd control to the field in the underlying table
  2. Place your calculation in the AfterUpdate event of the first control, assigning it to the 2nd control (Me.SecondControlName = [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.

Share this Question
Share on Google+
6 Replies


Jim Doherty
Expert 100+
P: 897
@Maris99
Welcome to Bytes :)

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 look
Attached Files
File Type: zip simplecalc.zip (12.9 KB, 47 views)
Apr 30 '10 #2

missinglinq
Expert 2.5K+
P: 3,532
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
  1. Change the Control Source of the 2nd control to the field in the underlying table
  2. Place your calculation in the AfterUpdate event of the first control, assigning it to the 2nd control (Me.SecondControlName = [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.
Apr 30 '10 #3

P: 3
Thanks guys both of the answers helped me a lot. Thanks again
Apr 30 '10 #4

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Apr 30 '10 #5

P: 3
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 guys
Apr 30 '10 #6

missinglinq
Expert 2.5K+
P: 3,532
You need to copy and then paste your exact code into a post so we can look at it.

Linq ;0)>
Apr 30 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.