By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,306 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

Form Text box calculations extended

P: 41
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
Apr 14 '08 #1
Share this Question
Share on Google+
5 Replies


ADezii
Expert 5K+
P: 8,597
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.
Apr 15 '08 #2

P: 41
THanks,

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. =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
Apr 15 '08 #3

ADezii
Expert 5K+
P: 8,597
THanks,

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. =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.
    Expand|Select|Wrap|Line Numbers
    1. Public lngRetVal As Long
  2. Execute the Compute() Function beforehand, and place its Return Value into a Publically Declared Variable named lngRetVal.
    Expand|Select|Wrap|Line Numbers
    1. lngRetVal = Compute([staffingDivisor],[student_enroll],[teacherfte],[sixth_grade_enroll])
  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.
    Expand|Select|Wrap|Line Numbers
    1. IIf([strudent_enroll]=0,0,lngRetVal)
  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.
    Expand|Select|Wrap|Line Numbers
    1. lngRetVal now contains the Return Value of the Compute() Function, if IIF() evaluates to False.
Apr 15 '08 #4

P: 41
This worked out perfectly. Thank you again,

Patti
Apr 16 '08 #5

ADezii
Expert 5K+
P: 8,597
This worked out perfectly. Thank you again,

Patti
You are quite welcome, Patti.
Apr 17 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.