Form Text box calculations extended

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patriciashoe
    New Member
    • Feb 2008
    • 41

    Form Text box calculations extended

    I have a textbox in a form that is derived by the use of a function that I created. This is working just fine. I now have the need to take this value and apply some additional logic to the value to determine a new value for another form textbox. The question - what is the best way to refer to this value in the new form text box? Do I h ave to repeat the control source from the first text box to perform the calculations in the new textbox? Thanks,

    Patti
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by patriciashoe
    I have a textbox in a form that is derived by the use of a function that I created. This is working just fine. I now have the need to take this value and apply some additional logic to the value to determine a new value for another form textbox. The question - what is the best way to refer to this value in the new form text box? Do I h ave to repeat the control source from the first text box to perform the calculations in the new textbox? Thanks,

    Patti
    Kindly rephrase your question and be more specific in certain areas:
    1. I assume you are creating this Text Box pro grammatically, post the code.
    2. What do you mean when you state that the Text Box is 'derived' by the use of a Function?
    3. You state you need to take a value, apply additional logic to the value, and use this for another Form. What value are you referring to?
    4. Is this new Text Box being created from the same Procedure as the original?
    5. You ask if you need to repeat the Control Source from the 1st Text Box to perform the calculations. What calculations?
    6. Until these and other possible questions are answered, I'm afraid you won't be getting much help in the form of Replies.

    Comment

    • patriciashoe
      New Member
      • Feb 2008
      • 41

      #3
      THanks,

      Here is the code:

      Code:
      =IIf([strudent_enroll]=0,0,compute([staffingDivisor],[strudent_enroll],[teacherfte],[sixth_grade_enroll]))

      I need to apply some additional logic against this number. Compute is a function I wrote that does some basic maty based on table values. This code produces a number, for example 25. I need to take 25 and apply some further logic to see where 25 compares on a scale for another measurement. I will most likely use a case statement to check for these new values. This new value needs to show up in a new textbox. Hope that clears it up.

      Patti

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by patriciashoe
        THanks,

        Here is the code:

        Code:
        =IIf([strudent_enroll]=0,0,compute([staffingDivisor],[strudent_enroll],[teacherfte],[sixth_grade_enroll]))

        I need to apply some additional logic against this number. Compute is a function I wrote that does some basic maty based on table values. This code produces a number, for example 25. I need to take 25 and apply some further logic to see where 25 compares on a scale for another measurement. I will most likely use a case statement to check for these new values. This new value needs to show up in a new textbox. Hope that clears it up.

        Patti
        Patti, you gave no indication as to the return value of the Compute(0 Function, except that it is a Number. Is it a BYTE, INTEGER, LONG, SINGLE, or DOUBLE? For the purpose of this discussion, I'll just assume it is a LONG.
        1. Declare a Variable to represent the Return Value of the Conpute() Function in a Standard Code Module, call it lngRetVal.
          [CODE=vb]Public lngRetVal As Long[/CODE]
        2. Execute the Compute() Function beforehand, and place its Return Value into a Publically Declared Variable named lngRetVal.
          [CODE=vb]lngRetVal = Compute([staffingDivisor],[student_enroll],[teacherfte],[sixth_grade_enr oll])[/CODE]
        3. Since both clauses of the IIF() will be evaluated anyway, place the Variable containing the Return Value lngRetVal into the IIF() Construct, not the actual Function.
          [CODE=vb]IIf([strudent_enroll]=0,0,lngRetVal)[/CODE]
        4. You can now Reference the Return Value of the Compute Function from anywhere in your Application via the Variable lngRetVal, since it was declared Publically.
          [CODE=text]lngRetVal now contains the Return Value of the Compute() Function, if IIF() evaluates to False.[/CODE]

        Comment

        • patriciashoe
          New Member
          • Feb 2008
          • 41

          #5
          This worked out perfectly. Thank you again,

          Patti

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by patriciashoe
            This worked out perfectly. Thank you again,

            Patti
            You are quite welcome, Patti.

            Comment

            Working...