473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Apr 14 '08 #1
5 2242
ADezii
8,834 Expert 8TB
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
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
8,834 Expert 8TB
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
This worked out perfectly. Thank you again,

Patti
Apr 16 '08 #5
ADezii
8,834 Expert 8TB
This worked out perfectly. Thank you again,

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

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

Similar topics

9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
4
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the...
11
by: ian.davies52 | last post by:
Is there anything I can do about the apparent limit on the number of textboxes that have calculations as their control source on a form or report in ms-access? I have a query that pulls together...
21
by: Simon Verona | last post by:
Hope somebody can help! I want to automatically be able to add code to the initialize routine on a Windows form when I add a custom control that I've written to a form. Specifically, I'm trying...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
6
by: txguy | last post by:
thanks for your help. we have a html form with multiple checkboxes, over 1210, and we are running a javascript that tallies total number of boxes and prices for the checkboxes the user selects. ...
1
by: tterb | last post by:
Hi there, Im a little stuck here, my problem is im making a house insurance form where you enter data into the feilds and the calculations link back to create the end result amount i cant seem to get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.