473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable Calculated values

41 New Member
Hi:

I have a need to have several different formulas for a calculated value on a form and report. Is there a way to store the formula in a field then refer to that field in the control source of the control property? Thanks,

Patti
Mar 9 '08 #1
20 3723
ADezii
8,834 Recognized Expert Expert
Hi:

I have a need to have several different formulas for a calculated value on a form and report. Is there a way to store the formula in a field then refer to that field in the control source of the control property? Thanks,

Patti
If I interpret you correctly, you must explicitly refer to the Formula/Function in the Control Source of the Control itself, and not to a Field containing the Formula. What, if I may ask, are you trying to accomplish?
Mar 10 '08 #2
patriciashoe
41 New Member
If I interpret you correctly, you must explicitly refer to the Formula/Function in the Control Source of the Control itself, and not to a Field containing the Formula. What, if I may ask, are you trying to accomplish?

I have a form with a calculated values that divides two fields. THis formula works for all but a few of the items in the form which requires a different calculation. In some cases the result that is currently obtained needs to further divided by another number.
Mar 10 '08 #3
ADezii
8,834 Recognized Expert Expert
I have a form with a calculated values that divides two fields. THis formula works for all but a few of the items in the form which requires a different calculation. In some cases the result that is currently obtained needs to further divided by another number.
Why not?
  1. Create a Calculated Field in the underlying Record Source for the Form. This Field would call a Public Function and pass to it the value of the Fields for each Record. Within the Function, the Fields would be analyzed, and the appropriate result would be passed back to the Calculated Field.
  2. Apply similar logic in the Form's Current() Event.
  3. If you need further clarification, just let me know.
Mar 10 '08 #4
patriciashoe
41 New Member
I can use a little more direction. Of the 150 records there are only six or seven that require a different formula. These records are flagged. Now, if you can elaborate just a little more on your solution, I can work through it. I can code but I have to work at it. thanks,

Patti
Mar 10 '08 #5
ADezii
8,834 Recognized Expert Expert
I can use a little more direction. Of the 150 records there are only six or seven that require a different formula. These records are flagged. Now, if you can elaborate just a little more on your solution, I can work through it. I can code but I have to work at it. thanks,

Patti
Kndly provide me a little more information, so that we can get your on the right track:
  1. Table Name.
  2. Field Names that are involved in the Formulas and their Data Types.
  3. Formula that is applied to 'Flagged' Records.
  4. Formula that is applied to 'Non-Flagged' Records.
  5. Flagged Field Name and Data Type.
  6. Value in 'Flagged' Field that sets the Flag (True, "FormulaB", etc.).
  7. Can either Field that is involved in the Formulas be NUll? (no value). If so, how do you handle this case?
  8. Any other info you see as relevant.
  9. I'll check back this afternoon, and we'll see what we can do.
Mar 10 '08 #6
patriciashoe
41 New Member
Thanks again,

The table is called teacherresoruce s. The fields are

buidlingID
TeacherFTE (number)
Enroll_students (number)
tr_year (number)
subjectID(numbe r) Note that in the subjects table there are unique subjectid, this is where I have a field called divisor to indicate a different formula. I was hoping to have the actual formula. Fro now it is a numeric field that I use to do the division as noted below.

The calculated value on the report and form is enroll_students/teacherFTE This works for 90 percent of the records. With the exception of two subjectid, the formula is changed as follows:

(student_enroll/teacherFTE)/5 or some other number. Right now I am doing the following. If there is no change in the formula the divisor is 1. Therefore the formula is (student_enroll/teacherfte)/[divisor]. I am plugging in the oher divisors and this seems to work. however, I anticipate greater complexity in the future so I don't know if this work around is viable in the long term. Two formulas are more involved and have to reference an enrollment field that is located on a sub form off the main form and is also part go query I am using. That is it in a nutshell. If you can get me moving in the right direction I can probably fill in the rest. Many thanks,

Patti
Mar 10 '08 #7
NeoPa
32,568 Recognized Expert Moderator MVP
One way that may work is to define a Public Function in a standard code module that can handle a list of different formulas.
You would pass (from your SQL) parameters reflecting the formula required and the variables to be used.
For instance :
Expand|Select|Wrap|Line Numbers
  1. Public Function Compute(ByVal Formula As String, _
  2.                         ByVal Students As Double, _
  3.                         ByVal TeacherFTE As Double, _
  4.                         ByVal Divisor As Double) As Double
  5.   Select Case UCase(Formula)
  6.   Case "MAIN"
  7.     Compute = Students / TeacherFTE / Divisor
  8.   Case "ALTERNATE1"
  9.     Compute = 3.14159 * Students / TeacherFTE
  10.   Case "ALTERNATE2"
  11.     Compute = TeacherFTE / Students / Divisor
  12.   End Select
  13. End Function
Mar 10 '08 #8
ADezii
8,834 Recognized Expert Expert
Thanks again,

The table is called teacherresoruce s. The fields are

buidlingID
TeacherFTE (number)
Enroll_students (number)
tr_year (number)
subjectID(numbe r) Note that in the subjects table there are unique subjectid, this is where I have a field called divisor to indicate a different formula. I was hoping to have the actual formula. Fro now it is a numeric field that I use to do the division as noted below.

The calculated value on the report and form is enroll_students/teacherFTE This works for 90 percent of the records. With the exception of two subjectid, the formula is changed as follows:

(student_enroll/teacherFTE)/5 or some other number. Right now I am doing the following. If there is no change in the formula the divisor is 1. Therefore the formula is (student_enroll/teacherfte)/[divisor]. I am plugging in the oher divisors and this seems to work. however, I anticipate greater complexity in the future so I don't know if this work around is viable in the long term. Two formulas are more involved and have to reference an enrollment field that is located on a sub form off the main form and is also part go query I am using. That is it in a nutshell. If you can get me moving in the right direction I can probably fill in the rest. Many thanks,

Patti
My old pal NeoPa has already pointed you in the right direction and has given the necessary logic.
Mar 11 '08 #9
patriciashoe
41 New Member
Thank you both!! I am on my way.

Patti
Mar 11 '08 #10

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

Similar topics

3
843
by: Stefanos | last post by:
Hi everybody, I need some help on calculated values in my database design. I'm creating an accounting / business management application with the usual modules like A/R, A/P, Inventory, etc. I don't know how to handle calculated values in fields like "Customer Balance", "Inventory Item Qty on Hand", "Inventory Item Qty Last cost" and other similar.
1
2628
by: Otto Porter | last post by:
/*Given*/ CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NULL , (2) NULL , NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
9
2168
by: Jack | last post by:
Hi, I got a asp form page where the POST ACTION = confirmation.asp page is used to save the values collected from text boxes from the form in a database. For example txtTotalOutlay field is being used in confirmation.asp page to update a database field. However, there is a field in the form which is calculated field e.g. NetOutlay = .90 * txtTotalOutlay. This NetOutlay is thus not a text field. However, in the confirmation field I...
10
2324
by: David Casey | last post by:
I'm working on a program for my C++ class and have it all written and working except for one part. I need to compare two numeric variables to determine decimal accuracy between them. For example: pi = 3.14159... mynum = 3.14226... The mynum is accurate to 2 decimal places compared to pi. I could figure this out easy with a char array since I could just take a character one at a time from each array and compare it. However with a...
1
2950
by: SJH | last post by:
I have been given an older database and asked to make upgrades and what not. One interesting thing I have come across with the database is that it was at one time set up so one of the tables would hold values that were calcuated using a form. I have looked at the code for all the text boxes on the assocatied forms and have yet to figure out how this was done. There were two values set up this way, one still works and the other one...
0
2070
by: Henry | last post by:
Hi Is there any good ideas how to update form vb code always after some values are changed / added by vb (not user). I have some code behind subforms vb and there are calculations behind "Form_Current" section those I need to re-calculate after some values are changed or added. The problem is that if list box value is calculated in vb, access wont
1
2178
by: douh | last post by:
I know that this is not the way, however I need to save certian calculated values so that they do not change over time, ie. new tax rates etc. This is for an invoice header and invoice subform. I have a form myheader and mysub that are linked via a invoice number. mysub calculates qty * list = extprice. I am summing these into a sum_ext field in mysub footer. I need to have this value updated into the myheader invsubtot. I have tried many...
19
2136
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit of a possibly large structure/field.
11
2343
by: James Hallam | last post by:
I have read through all the past topics and couldn't find what I was after so... I am looking to store some calculated values (don't flame just yet, just read on!). I have an piece of code behind a form which calculates a percentage completion and an expected completion date of a job. I would like to store this information in a separate table, along with the actual date the values were calculated. Whenever a job is completed I can...
29
4229
by: Martin | last post by:
For reasons I won't go into, I need to transfer from 1 to 3 bytes to a variable that I know is 4 bytes long. Bytes not written to in the 4-byte target variable must be zero. Is the following use of memcpy() a well-defined way of so doing? The code is written knowing that sizeof(unsigned long) == 4 in this instance. The code is somewhat contrived in order to provide a self-contained program that will compile and show the use of memcpy() I...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.