473,396 Members | 1,923 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,396 software developers and data experts.

Calculating and recording on the table from 12 fields in form

Hi,

I am new to Access and I seem to have run into a conundrum. I am currently using Ms Access 2007. I have a table setup with 12 fields and form with 12 fields which is corresponding to the 12 fields on the table.

The 12 fields on the form are combo box with setting
Row source: 1;"Yes";0;"No"
Column Count: 2
Column widths:0";2"

If I am correct, this allows the user to select Yes or No and have a corresponding values of 1 or 0 inputted in the table.

Now the real question is that I need to make a field that sums up the values from the 12 fields in the form and records it onto the table.

So far I have set the following up in the code builder

Expand|Select|Wrap|Line Numbers
  1. Private Sub Field1_AfterUpdate()
  2. Me.Total = Me.Field1 + Me.Field2 + Me.Field3 + Me.Field4 + Me.Field5 + Me.Field6 + Me.Field7 + Me.Field8 + Me.Field9 + Me.Field10 + Me.Field11 + me.Field12
  3. End Sub
  4.  
  5. Private Sub Field2_AfterUpdate()
  6. Call Field1_AfterUpdate
  7. End Sub
  8.  
The Afterupdate on Field2 is repeated for Fields 2-12.

I have a hunch I did something wrong in the code and would appreciate any help in solving the problem.

Also, I am willing to undertake any other methods other than code builder if it yields better results as long as the Total field sums the values of the fields 1-12 and records it in the table.
Jul 1 '10 #1
2 1476
NeoPa
32,556 Expert Mod 16PB
If you only have 12 fields in your table where would the sum be stored?

If you have common code that needs to be run by each of the 12 different AfterUpdate event procedures then it is a good idea to put that code in a separate subroutine procedure and call it from each of the 12 event procedures.

See Normalisation and Table structures for why storing calculated results (your totals in this case) is not recommended at all.

Welcome to Bytes!
Jul 1 '10 #2
missinglinq
3,532 Expert 2GB
Even better would be creating a query based on your form with a calculated field like:

Expand|Select|Wrap|Line Numbers
  1. TotalField: Nz([Field1]) + Nz([Field2]) + Nz([Field3])
and so forth for all 12 fields. You'd only need the formula in one place, wouldn't need to call it from each AfterUpdate event, and you'd have a field for the total.

Then you'd simply base your forms, reports, etc on the query.

Linq ;0)>
Jul 1 '10 #3

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

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
1
by: Mike S. Nowostawsky | last post by:
I need to be able to create a 2 column table and then based on which column header is clicked on, sort the list by that column so that each table row is sorted properly. If possible there might be...
4
by: Silas | last post by:
Hi, I use view to join difference table together for some function. However, when the "real" table fields changed (e.g. add/delete/change field). The view table still use the "old fields". ...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
2
by: jquest | last post by:
Hi Again; I am improving my database and have to overcome some original design mistakes. I have 3500 records in the table and I have had to insert new fields to track things I originally didn't...
3
by: DStark | last post by:
Hi! Is it possible to iterate through table fields in an ADP? What I'd like to do is: Sub PrintTableFields() Dim dbs As Object Dim tbl As AccessObject Dim fld As ???? Set dbs =...
4
by: yanjie.ma | last post by:
Hi, I've got a two part question on table and form design (sorry for the length but it takes a bit to explain). Our sales department uses a look-up table to help the them select the best...
1
by: Ste | last post by:
Hi, I would like to have current date automatically enter into a form that is based on a table, so that from report I can tell how many records I have entered for the day. If I use date() on...
1
by: zoeb | last post by:
Currently I have a table, and would like the calculate a field in the table by referencing values from another 3 tables. i.e. tblData Index1, Index2, Index3, Value 1 2 3 2...
3
by: davenumber40 | last post by:
I’m creating a small database in Access 2003(XP) to track issues during software testing. As far as databases go, it’s going to be a relatively small, short term project (No more than 20,000 records...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.