how to calculate textboxes in a report?

behedwin

Active Member
Joined
Dec 10, 2014
Messages
399
I have a report with 7 textboxes that are populated from a query.

I have created a 8th textbox where i want to sum up the textboxes.

the first 7 textboxes are short text in the table.
the 8th textbox i want to write a formula so it takes the current value of the 7 textboxes and show me a total value
textbox 1 + textbox 2 + textbox 3 + textbox 4...........


how do i do this?
it does not work to just type in the data field
=[textbox1]+[textbox2].....
i get no errors and no result
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Are they numbers to be added or text to be joined? Is there grouping in the report and you're crossing levels to sum the textboxes? Can you calculate the sum in a query and add that to the report instead?
 
Upvote 0
I tried to solve this with VBA
but i get null errors now

i also changed the table objects from short text to number.

Code:
Dim tot1 As Double
Dim tot2 As Double
Dim tot3 As Double
Dim tot4 As Double
Dim tot5 As Double
Dim tot6 As Double
Dim tot7 As Double
Dim total As Double

tot1 = Report_Lonfordel.t1.Value
tot2 = Report_Lonfordel.t2.Value
tot3 = Report_Lonfordel.t3.Value
tot4 = Report_Lonfordel.t4.Value
tot5 = Report_Lonfordel.t5.Value
tot6 = Report_Lonfordel.t6.Value
tot7 = Report_Lonfordel.t7.Value

total = tot1 + tot2 + tot3 + tot4 + tot5 + tot6tot7

      Report_Lonfordel.txttotal.Value = total
but this code gives me error on null value
 
Upvote 0
i changed it to be numbers.

but still not getting the correct answer...

i noticed if i got any of the texboxes empty (sometimes they are). Then i get no result when calculating.
i need the calculation to work even if some of the textboxes are empty.
 
Upvote 0
Dont get it...
googled around on how to set the default value on a textbox, but it seems i cant?!

and if i look in my table the default value of the record is already set to 0

but when i calculate the textboxes i get no answer if one of them is empty.
 
Upvote 0
That worked.... but when a user deletes the 0 from any textbox... and just leaves it empty.
The calculations stops to work.

So can i setup so that there must be a value atleast or make the calculation work even if one of the textboxes are empty.

default value works. but if a user takes away the 0
then it is not put back in by default value....
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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