Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing a sum from a control box into a table.

Status
Not open for further replies.

Kingsteveiv

Technical User
Oct 8, 2001
20
US
Hello again.

I have three control boxes and I add the three using the expression builder in the fourth control box. I want to put the value thats in the fourth control box into a feild in a table. Is there a code that will allow me to do this, or any other way that will allow this to happen? Please let me know if possible!

Thanks a lot!
 
Calculated controls really should not be stored in a table. It violates the rules of normalization.

Since you can always calculate this total whenever you need it for a form or report, there is no need to take up space in the database for it. Maq B-)
<insert witty signature here>
 
The problem is that the calculated control is specific to a customer in the form. I would then need that control to go into another form to do another calculation, once again specific to that customer.

Is it possible for me to create a calculated control on the second form that refers to that calculated control from the first one? What sytax would i use to retrieve that information?

steve

 
Well you can either re-calculate it in the 2nd form or if the 1st form is still open you can reference it with the syntax [forms]!formname!calcfield
Maq B-)
<insert witty signature here>
 
Referencing it when the other form is still open works, exept, that it only returns the value of the current form that is displayed.

This is my dilema:

2 forms

Form1 - Customer Totals
Form2 - All Customer Totals
Subform (Form2) - Customer Totals

I have values that are calculated in a form based on information of the specific customer. The second form(where i want to return the values) is a subform with a combobox that I can select the customer from. When i select the customer from the combobox in the subform, i want it to display the calculation i made on the first form.

What can i do to display the customer specific value that i need from the first form where i made the calculations?

thxs

steve
 
I would suggest re-calculating it then. Maq B-)
<insert witty signature here>
 
I would go ahead and recalculate it, exept, its a pretty extensive calculation to ultamtly get what i want. In the form all i want to display is the name of the customer and its total.

I appriciate your help and is there anyway I could do this at all??

steve
 
Well, I'll admit I don't understand your database structure completely. You pull up a customer in form1 and calculate this field. You then move off of that customer before opening form2, so the field is no longer available?

Why can't form1 call form2 and display the appropiate customer without having to reselect the customer in form2. That way you could pull the field from form1.

Another option would be to create a query containing all the necessary fields for form2 as well as the calculated field. That way you would also have it available and you wouldn't have to mess with passing fields between forms.

If anyone else has a better solution, please feel free to jump in here. Maq B-)
<insert witty signature here>
 
thanks for your help, but im just going to go about everything another way.

thxs again

steve
 
Maquis is giving you very good advice. You should not store calculated results in your table. I strongly recommend you heed it. If you need more help with the specifics of how to accomplish what you want through the use of queries or SQL I or anyone else here will be more than happy to help you.
 
You Can Do this,

Go to the control which is doing your calculate then write under onexit......event...

[The Field That you Want to store the value] = me.&quot;the Control name&quot;]

for example:
[LineTotal] = me.Calculated

Good Luck
 
Haitham, this is very bad advice .....

Both Marquis and Jerry could have easily told him how to save the result in the table. But as both replied &quot;it is not the proper thing to do&quot;. This breaks the &quot;Rules of Relational Database Normalization&quot; and will almost always come back to &quot;bite you in the butt&quot; later. You never save the result of a calulation to a record in the table except in certain special occasions, and this does not appear to qualify.

RDH
Ricky Hicks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top