Link to home
Start Free TrialLog in
Avatar of AWSA
AWSA

asked on

"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?
Avatar of David Lee
David Lee
Flag of United States of America image

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?
Avatar of AWSA
AWSA

ASKER

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".

Any comments appreciated...
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?
Avatar of AWSA

ASKER

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.
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

Open in new window

Avatar of AWSA

ASKER

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.

Any comments appreciated....
Avatar of AWSA

ASKER

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.

I appreciate your assistance.
Avatar of AWSA

ASKER

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?
Avatar of AWSA

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AWSA

ASKER

Great job!
Thanks!
Avatar of AWSA

ASKER

Just sent you an email....