Hello i am very new to access but wondered if there is a way to add a formula in the database. I have 6 text box's which will all contain figures and i wanted it to total them all up and display at the bottom. Can this be done? Many thanks
=Tbox1+Tbox2+Tbox3 etc.
Please please help i only need to resolve this and the error OpenForm was cancelled and my database will finally be complete.
Although this code will run, the SUM part is redundant if you've used the + operator. You only need the SUM if you have a comma separated list.=Sum(Nz([Box1],0) + Nz([Box2],0)) ...etc.
No, you need the SUM part if you have the control in the FOOTER (which is what the OP asked:Although this code will run, the SUM part is redundant if you've used the + operator. You only need the SUM if you have a comma separated list.
louisa said:i wanted it to total them all up and display at the bottom
According to the OP it's only the total of the six boxes which has to be displayed in the footer which does not require the SumNo, you need the SUM part if you have the control in the FOOTER (which is what the OP asked:
Option Compare Database
Option Explicit
Private Sub CalculateTotals()
Dim ctlTotal As Long, i As Integer
ctlTotal = IIf(IsNumeric(SetupPrice), SetupPrice, 0)
For i = 1 To 6
ctlTotal = ctlTotal + IIf(IsNumeric(Me.Controls("SetupPrice" & i).Value), Me.Controls("SetupPrice" & i).Value, 0)
Next
Text89 = ctlTotal
End Sub
Private Sub SetupPrice_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice1_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice2_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice3_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice4_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice5_AfterUpdate()
Call CalculateTotals
End Sub
Private Sub SetupPrice6_AfterUpdate()
Call CalculateTotals
End Sub