• Status: Solved
• Priority: Medium
• Security: Public
• Views: 226

# "Displaying Formula Values in Custom Contact Forms"

I have a custom contact form.  I have some values that are calculated in the form and I want to put those values into one field.  For example I calculate a value in separate fields for A, B & C with formulas.  I want to take the results of those fomulas for A, B & C and put them into one text field called Summary the will read as follows:

Value for A = (the calculated amount)
Value for B = (the calculated amount)
Value for C = (the calcuated amount)

The problem is that when I put a reference to a caluculated field in the Summary field the values do not get updated.

Any thoughts?
0
AWSA
• 8
• 5
1 Solution

Commented:
Hi, AWSA.

So, you want it to read exactly like this

Value for A = (the calculated amount for A)
Value for B = (the calculated amount for B)
Value for C = (the calculated amount for C)

Is that correct?
0

Author Commented:
Yes.  Note that I do calcuate the values for A, B and C with different formulas in separate "formula fields" for each on the custom form.  The problem occurs when I put the "formula fields" with the calculated value into the "text summary field".  The "text summary field" will not update the information.  It is like it makes the "text summary field" goes dead.  I have some other "text fields" that I am putting into the "text summary field" as well and the "text fields" will not adjust either when I have the "formula fields" adding data to the "text summary field".

0

Commented:
How are you adding the values in?  Are you using the approach I showed in the last question or are you doing it some other way?  If another way, how?
0

Author Commented:
I am a very very baisic programmer by just using basic algebra skills etc.  I put the formula in the little pop-up box and then check calculate automatically.  That is the only way I know how to do it.  I think I need some script like on the previous question.
0

Commented:
Correct.  This isn't working for the same reason it didn't work in the other question.  The good news is that the code required is very similar to the code required in the other question.  Here's what you need to do

1.  Add three textbox controls to the form.  Name them txtFieldA, txtFieldB, and txtFieldC.  Bind them to three user-defined properties named (respectively) FieldA, FieldB, and FieldC.

2.  Add a textbox control to the form.  Name it txtComposite.  Bind it to a user-defined property named Composite.

3.  Open the Advanced Properties of txtComposite and make the following changes:
- MutliLine = True
- WordWrap = False

4.  Add the following code to the form.  I don't know what formula you're using for each field, so you'll have to adjust the code to include the calculation for each.  To do that you'll need to edit the formula in the code for each field.  I placed a comment line each place where that needs to occur.

You don't have to use the same field and property names that I've used.  Just remember that if you change them, then you have to change them everywhere they're used, bot on the properties of the controls and in the code.
``````Sub Item_CustomPropertyChange(strName)
Select Case strName
Case "FieldA","FieldB","FieldC"
Item.UserProperties.Item("Composite") = _
"Value for A = (" & Field_A_Formula() & ")" & vbLf _
& "Value for B = (" & Field_B_Formula() & ")" & vbLf _
& "Value for C = (" & Field_C_Formula() & ")"
End Select
End Sub

Function Field_A_Formula()
'Edit the calculation on the next line'
Field_A_Formula = Item.UserProperties.Item("FieldA").Value
End Function

Function Field_B_Formula()
'Edit the calculation on the next line'
Field_B_Formula = Item.UserProperties.Item("FieldB").Value
End Function

Function Field_C_Formula()
'Edit the calculation on the next line'
Field_C_Formula = Item.UserProperties.Item("FieldC").Value
End Function
``````
0

Author Commented:
I need some help with the following.  When you say:

1.  Add three textbox controls to the form.  Name them txtFieldA, txtFieldB, and txtFieldC.  Bind them to three user-defined properties named (respectively) FieldA, FieldB, and FieldC.

For A, does this mean:  Create a new text field named:  txtFieldA; add it to the form somewhere; right click on it and go to Properties, Value, Initial Value, Edit, and then insert the FieldA in the formula are so that txtField A is now "bound" to FieldA.

0

Author Commented:
Or do you just want me to create three user new user defined text fields named txtFieldA, txtFieldB, and txtFieldC and add them to the form?

I think you have stated it much more eloquently than my "novice language" above.

0

Author Commented:
Thank you so much for your assistance.  I am going to do my best to get this done.

However, I must ask this question, is there anyone that I can call who can do this remotely?
0

Author Commented:
I spoke with the customer service group at EE and they told me that it if I accept the solution you provided it is within the EE guidelines for us to communicate outside of EE to implement the solution.  Just a thought.  I understand if you are not interested in implementation.  Your assistance has been great!
0

Commented:
For A, does this mean:  Create a new text field named:  txtFieldA; add it to the form somewhere; right click on it and go to Properties, Value, Initial Value, Edit, and then insert the FieldA in the formula are so that txtField A is now "bound" to FieldA.

Partially.  Create a new text field.  Right-click on the field and select Properties.  Set the name to txtFieldA.  Click on the Value tab.  Click the New button to the right of Choose Field.  When the New Field dialog-box appears enter FieldA in the name field.  Set the Type and Format, then click OK.  The control is now bound to the field.  Repeat for the other controls/fields.

----

Thanks.  I prefer not to do this myself, but I don't mind talking you through doing it so long as you're either in the US or are on Skype.  My email address is in my profile.  If you send me an email, then I'll see if we can arrange a time to talk.  I'll need to know what time zone you're in to work that out.  I'm in the US, Eastern timezone.
0

Author Commented:
Great job!
0

Commented:
Thanks!
0

Author Commented:
Just sent you an email....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.