Calculating

jcurtoys

Board Regular
Joined
Oct 11, 2004
Messages
56
I would like to create a field that will calculate values entered in other fields on same form plus one other from a table to give me a total
:oops:
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Without knowing your detailed layout I can only be generic but here's the idea:
Say you have 3 fields [Text1], [Text2], [Text3] and you want to keep [txtTotal] updated. For EACH field that contributes to the total, you'll need to do this --
1. Right-click the text box in Design view, select Properties. Click on the Event tab.
2. In the blank After Update line, double-click to show Event Procedure. Now click the Builder (...) button to go to the code sheet. Enter this:
[txtTotal] = Nz([Text1]) + Nz([Text2]) + Nz([Text3])

Save the form and try it out. The Nz wrapper converts null or empty values to zero so Access can add them up -- otherwise it tends to choke.

Denis
 
Upvote 0
Is there a reason to do the calculation on the form? Any calculation should be done in a query and not on the form. SydneyGeek's answer will work if all the fields are in the same table. If you are going to use a value from another table, you will have to use the DLookup function to capture that value.
 
Upvote 0
Here what I am trying to do...
I have a form that employees enter information to find out yeild.
=([Total_Good_Parts_Completed]/(([Machine_End]-[Machine_Start])*[Cavities]))
Three of the values are in the same table but cavities are pulled from another based on the previous part entered through VBS.
Private Sub Form_Current()
Cavities = Die_No.Column(1)
Die_No.RowSource = "SELECT DIE.Die_No, DIE.Die_Cavities FROM DIE INNER JOIN PART_DIE ON DIE.Die_No = PART_DIE.Die_No WHERE (((PART_DIE.Part_No)=[Forms]![frmMain]![Part_No]))"

End Sub

I get an error when I try to run it. I didn't build this database just inherited it and the one that built it is more advance than myself. :pray:
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top