473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to sum fields and update a table using that info??

Scenario : i have a table
tblOne - SCID , BoxSetNo , BoxesInBoxSet
--------------1----------1------------5
--------------1----------2------------7
--------------1----------3------------9
--------------2----------1------------3
--------------2----------2------------7

so what i want is , in a form i need to have a textbox where the sum of SCID 1 should display(in this case 21), so i can do more calculations with that value
form's record source is a different table!!
i can add the field from other tables, but it only shows one record (SCID 1 and the value is 5 not 21) not the sum of it

pls how to calculate the sum of a field in a textbox??
Jun 20 '20 #1
3 1998
cactusdata
214 Expert 128KB
Use this expression as control source for your textbox:

Expand|Select|Wrap|Line Numbers
  1. =DSum("BoxesInBoxSet","tblOne","SCID = " & [SCID] & "")
Jun 20 '20 #2
NeoPa
32,556 Expert Mod 16PB
Generally speaking those who work with databases understand, to a greater or lesser extent, the concepts of Normalisation (See Database Normalisation and Table Structures). As such, we would very rarely recommend updating tables to reflect calculated values.

Immediately you have data that is already stale. Sometimes, very rarely in my experience, it is necessary, or at least helpful/easier, to create data in a table temporarily that can be used - but not stored long-term.

There are many ways to get totals into a Control on a Form. CactusData has illustrated one. Another very simple one is to ensure there is a calculated field in the SQL used to source your Form. Aggregating the source data typically ensures the dataset isn't updatable though so that should always be taken into consideration.

Appending data into a temporary table can be done with an Append query based on an aggregated SELECT section. I'll go into more detail on that if required but please understand I am not recommending this approach. In fact, my advice is to avoid it like the plague if you have any alternative.
Jun 20 '20 #3
Thanks alot Guys!!
Helpful Tips Saved Me
Jun 21 '20 #4

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

Similar topics

1
by: DChrist | last post by:
I am unable to update a table (either by opening it and entering data directly or through a form). I have set the recordsettype property to updateable snapshot and have set the permissions to...
4
by: gj | last post by:
Hi, I'm trying to update a sql database from a web form using text boxes. I'm trying to learn C# on my own so I am at a complete loss. I created my sql connection, data adapter, dataset and data...
2
by: DanLezoche | last post by:
i have a client who's database requires users to enter the beginning date and ending date for contracts. i would like to create a vba function that checks the end date w/ the now() function (from...
1
by: Bo Long | last post by:
I believe the following a valid SQL statement, but MS Access returns with an error "Operation must be an updateable query". Any suggestions would be greatly appreciated! UPDATE FERCPTILoad AS...
5
by: SQL Learner | last post by:
Hi Alex (Kuznetsov) and All, This is to follow up with my last post, "Link two tables using partial word match". How can I UPDATE table using partial word match? How can I write a SQL statement...
3
by: Ciara9 | last post by:
I am having problems trying to update a field in a database using a field in a form. I currently have two fields, Today and Tomorrow in a table named Date. The Today field automatically defaults to...
4
by: slavisa | last post by:
Im having trouble with updating my 1 table with the information from another! I have a table with 6 fields. Code(pk), Name, Title, Address, State, city, zip the table is called Info. Now...
1
benchpolo
by: benchpolo | last post by:
I have 2 tables Table 1: Invoice Table 1 fields: ClientName, PostedPaid (Yes/No) Table 2: History Table 2 fields: ClientName, DatePaid Overview In form level when the user click SAVE the...
1
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK ...
1
by: zeusads | last post by:
Hello, I have a little problem, if anyone can help! I have these 2 tables Products: ID Product Category Current Stock
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.