How to Add values of Two Fields and Save that Value in a Table Field?

JithuAccess

Member
Local time
Today, 04:37
Joined
Mar 3, 2020
Messages
325
Hello Guys,

A very simple question. I have three fields "Team A" , "Team B" and "Total". When a user enter an Amount in "Team A" and "Team B" I want to display the total in the field "Total" and store the Total value in the Total Field of the Table. Is there any method to do so?

This is my Form:

1611760725362.png


In the Control Source Property of "Total" I have entered like:

1611760822435.png


And this is my Table:

1611760861957.png


Here I want to store the sum of $5.00 and $10.00 and $15.00 in Total Field.

Thanks
 
It is a general principle of Access programming that you not do this. If you want something that involves a computation, the general rule is that you build a query that performs this summation on-the-fly. You MIGHT generate a query that looks like

Code:
SELECT [Team A], [Team B], [Team A] + [Team B] As Total FROM mytable;

For a simple case such as yours, it might not seem to matter to you, but for larger tables with multiple fields to be summed in this way, the space you save can add up. In your case, if you have 1000 records and the total is a SINGLE field, not storing it would save you 4 kb.

The thing to understand is that you can use that query as a recordsource for printout and report generation just like you can use a table as a recordsource for those purposes. Access doesn't care most of the time.
 
It is a general principle of Access programming that you not do this. If you want something that involves a computation, the general rule is that you build a query that performs this summation on-the-fly. You MIGHT generate a query that looks like

Code:
SELECT [Team A], [Team B], [Team A] + [Team B] As Total FROM mytable;

For a simple case such as yours, it might not seem to matter to you, but for larger tables with multiple fields to be summed in this way, the space you save can add up. In your case, if you have 1000 records and the total is a SINGLE field, not storing it would save you 4 kb.

The thing to understand is that you can use that query as a recordsource for printout and report generation just like you can use a table as a recordsource for those purposes. Access doesn't care most of the time.
Thanks a lot for your Reply.
 

Users who are viewing this thread

Back
Top Bottom