Automatically Calculate fields on a form

alinka

Board Regular
Joined
Oct 30, 2002
Messages
70
Hi,

On a FORM, I have 4 fields which ask for numbers to be entered into them.

I have a 5th field in which I want the total of the above 4 fields to be automatically inputted. How do I do that? It's probably putting a SUM formula into the properties of the 5th field, but I tried it and it didn't work. I put =[field1]+[field2]+[field3]+[field4] but that doesn't work.

Could someone please help me with how this 5th field can automatically display this TOTAL of the 4 fields above. Thanks soooo very much!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Is this a field that will be captured in an underlying table or just something that you want to dynamically view?
 
Upvote 0
Dear Dugantrain,

Thanks for your response. I will definitely want to capture the "total" field in the underlying table..., while still displaying the "total" on the form. Hope this helps.
 
Upvote 0
You'd need to do some coding. Here's one way to do it
Field1_AfterUpdate()
Call MyFunction
End Sub

Field2_AfterUpdate()
Call MyFunction
End Sub

Field3_AfterUpdate()
Call MyFunction
End Sub

Field4_AfterUpdate()
Call MyFunction
End Sub

MyFunction
Field5=Field1+Field2+Field3+Field4
End Function
 
Upvote 0
Dear Dugantrain,

Thanks again for helping. I am a beginner access user. Could you please kindly tell me where I put this code? I don't really know where to put it. Thanks so much!
 
Upvote 0
-Go to design view
-Select the code icon from the toolbar(it's the icon with the green, yellow, and red points).
-You'll now be in the code window,where you'll write your code. Don't just copy and paste what I gave you, though, you'll need to give the subs the same name as your textboxes on your form. I understand that making a first foray into code can be confusing; if you can't get it to work, then post back and I'll help you.
 
Upvote 0
still need prepopulating help

Hi again!

I tried inserting code, but code a code "variable" error. I think I'm inserting it the wrong way, even though I followed instructions.

May I email you my form so that You see what it looks like?

-Alina
 
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,152
Members
451,625
Latest member
sukhman

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