Sum two fields together

  • Thread starter PRodgers4284 via AccessMonster.com
  • Start date
P

PRodgers4284 via AccessMonster.com

I want to sum two fields together but im unsure how to do this, i have two
field called "Opp_Total" and "Action_Total" and i would like to add the
values from this two fields together. Can anyone provide some help?
 
G

Gina Whipp

PRodgers4284,

In an unbound field on a form and/or report you can place
=[Opp_Total]+[Action_Total]

However, you did not mention where it is you are tyring to sum these two
fields so my suggestion may not be applicable. A few more details are
required if the above does not answer your question.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
G

Golfinray

I want to sum two fields together but im unsure how to do this, i have two
field called "Opp_Total" and "Action_Total" and i would like to add the
values from this two fields together. Can anyone provide some help?
 
J

John W. Vinson

I want to sum two fields together but im unsure how to do this, i have two
field called "Opp_Total" and "Action_Total" and i would like to add the
values from this two fields together. Can anyone provide some help?

Your question is a bit ambiguous: do you want just a simple sum of two
numbers? If so Gina's first suggestion is the way to go. Or do you want a
grand total summing adding the two fields in each record and summing those
sums across multiple records? If so Golfinray's Sum() would work.

A bit more context would certainly help!
 
P

PRodgers4284 via AccessMonster.com

Hi my vb code for the form at present is:

Option Compare Database
Private Sub Action_Total_DblClick(Cancel As Integer)
Me.Action_Total = IIf(Action1 Like "rub*", 1, 0) + IIf(Action2 Like "rub*", 1,
0) + IIf(Action1 Like "wash*", 1, 0) + IIf(Action2 Like "wash*", 1, 0)
End Sub


Private Sub Form_Current()
Me.Opp_Total = (IIf(IsNull([txtIndication1]), 0, 1)) + (IIf(IsNull(
[txtIndication2]), 0, 1)) + (IIf(IsNull([txtIndication3]), 0, 1))
Me.Action_Total = IIf(Action1 Like "rub*", 1, 0) + IIf(Action2 Like "rub*", 1,
0)

End Sub
Private Sub Opp_Total_DblClick(Cancel As Integer)
Me.Opp_Total = (IIf(IsNull([txtIndication1]), 0, 1)) + (IIf(IsNull(
[txtIndication2]), 0, 1)) + (IIf(IsNull([txtIndication3]), 0, 1))
End Sub

Private Sub Q_Total_DblClick(Cancel As Integer)

End Sub


Code for my query is:

SELECT testbw.id, testbw.Indication1, testbw.Action1, testbw.Indication2,
testbw.Action2, testbw.Indication3, testbw.Action4, Sum((IIf(IsNull(
[Indication1]),0,1))+(IIf(IsNull([Indication2]),0,1))+(IIf(IsNull(
[Indication3]),0,1))) AS indcount, Sum(IIf([action1] Like "rub*",1,0)+IIf(
[action2] Like "rub*",1,0)) AS countaction, [indcount]*[countaction] AS Total
FROM testbw
GROUP BY testbw.id, testbw.Indication1, testbw.Action1, testbw.Indication2,
testbw.Action2, testbw.Indication3, testbw.Action4;


My form uses the info from the query, hope that makes it abit clearer.





Gina said:
PRodgers4284,

In an unbound field on a form and/or report you can place
=[Opp_Total]+[Action_Total]

However, you did not mention where it is you are tyring to sum these two
fields so my suggestion may not be applicable. A few more details are
required if the above does not answer your question.
I want to sum two fields together but im unsure how to do this, i have two
field called "Opp_Total" and "Action_Total" and i would like to add the
values from this two fields together. Can anyone provide some help?
 
G

Gina Whipp

PRodgers4284 ,

So you want this to show in a form footer? Or is this a continuous form
that you want to show it line by line?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

PRodgers4284 via AccessMonster.com said:
Hi my vb code for the form at present is:

Option Compare Database
Private Sub Action_Total_DblClick(Cancel As Integer)
Me.Action_Total = IIf(Action1 Like "rub*", 1, 0) + IIf(Action2 Like
"rub*", 1,
0) + IIf(Action1 Like "wash*", 1, 0) + IIf(Action2 Like "wash*", 1, 0)
End Sub


Private Sub Form_Current()
Me.Opp_Total = (IIf(IsNull([txtIndication1]), 0, 1)) + (IIf(IsNull(
[txtIndication2]), 0, 1)) + (IIf(IsNull([txtIndication3]), 0, 1))
Me.Action_Total = IIf(Action1 Like "rub*", 1, 0) + IIf(Action2 Like
"rub*", 1,
0)

End Sub
Private Sub Opp_Total_DblClick(Cancel As Integer)
Me.Opp_Total = (IIf(IsNull([txtIndication1]), 0, 1)) + (IIf(IsNull(
[txtIndication2]), 0, 1)) + (IIf(IsNull([txtIndication3]), 0, 1))
End Sub

Private Sub Q_Total_DblClick(Cancel As Integer)

End Sub


Code for my query is:

SELECT testbw.id, testbw.Indication1, testbw.Action1, testbw.Indication2,
testbw.Action2, testbw.Indication3, testbw.Action4, Sum((IIf(IsNull(
[Indication1]),0,1))+(IIf(IsNull([Indication2]),0,1))+(IIf(IsNull(
[Indication3]),0,1))) AS indcount, Sum(IIf([action1] Like "rub*",1,0)+IIf(
[action2] Like "rub*",1,0)) AS countaction, [indcount]*[countaction] AS
Total
FROM testbw
GROUP BY testbw.id, testbw.Indication1, testbw.Action1,
testbw.Indication2,
testbw.Action2, testbw.Indication3, testbw.Action4;


My form uses the info from the query, hope that makes it abit clearer.





Gina said:
PRodgers4284,

In an unbound field on a form and/or report you can place
=[Opp_Total]+[Action_Total]

However, you did not mention where it is you are tyring to sum these two
fields so my suggestion may not be applicable. A few more details are
required if the above does not answer your question.
I want to sum two fields together but im unsure how to do this, i have
two
field called "Opp_Total" and "Action_Total" and i would like to add the
values from this two fields together. Can anyone provide some help?
 
Top