Adding Switch Text Boxes (1 Viewer)

fuel52

New member
Local time
Today, 05:26
Joined
Jul 16, 2003
Messages
9
How would I go about adding numeric values from 2 textboxes produced by a switch function?

Example:

Text box #1 - Control Source: =Switch([Q4]="1","7",[Q4]="2","6",[Q4]="3","5",[Q4]="4","4",[Q4]="5","3",[Q4]="6","2",[Q4]="7","1")

Text box #2 - Control Source: =Switch([Q11]="1","7",[Q11]="2","6",[Q11]="3","5",[Q11]="4","4",[Q11]="5","3",[Q11]="6","2",[Q11]="7","1")

In this report, i need to add the two numbers that result from this switch function, is that possible?

I try to make a new textbox and in the control source function i try this: =Sum([Text1]+[Text2]) but it's not working.

Any ideas on how I can get the results from these two switch function text boxes to calculate?
 
Sum() is an aggregate function. All you are doing is adding two text boxes. Aggregate functions won't work with unbound fields (your two textboxes are unbound since they contain calculated values. The controlSource should be:

=[Text1]+[Text2]
 
Okay, I'm with you so far. But, when I do that, for example, if one text box value is "2" and the second text box "3", and i put =[Text1]+[Text2] then it shows 23 instead of adding the two numbers to 5.
 
That's because the + is concatenating the values rather than adding them. That is the behaviour of the + when one or both operands are text.

If Q4 is numeric, get rid of ALL the quotes in the Switch() functions. If not, just get rid of the ones enclosing the answers. Numeric fields should NOT be enclosed in quotes. Only Strings should be enclosed in quotes.

If that still doesn't solve the problem, convert the data.

=CInt([Text1]) + CInt([Text2])
 
Q4 is numeric, so removing the quotes did it!

Thanks Pat, u rule.
 

Users who are viewing this thread

Back
Top Bottom