# Calculating

#### jcurtoys

##### Board Regular
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

### Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

#### SydneyGeek

##### MrExcel MVP
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

#### Tanis

##### Active Member
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.

#### jcurtoys

##### Board Regular
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. ray:

Replies
1
Views
164
Replies
5
Views
215
Replies
2
Views
330
Replies
2
Views
75
Replies
11
Views
840

1,195,582
Messages
6,010,580
Members
441,557
Latest member
Jbest23

### 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.

### Which adblocker are you using?

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

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