OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Filed calculate from another

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
sirio81
General User
General User


Joined: 08 Mar 2007
Posts: 12

PostPosted: Tue Jan 27, 2009 3:50 am    Post subject: Filed calculate from another Reply with quote

Hi all, I have a "simple" question: guess a table with just 4 fields

id
euro/kg
kg
total

Now I have a form where I can insert the filed "euro/kg" an "kg".
The field "total" is the result of "euro/kg" X "kg". I wish this value to be insert automatically.

I can guess two ways for do that:

1-do something (you tell me what Smile on the table structure so it will populate the "total" field using the formula.
In this case we do not need to add the field "total" to the form.

2-add the field "total" to the form and do something (you tell me what Smile so its value will be that formula result that will be (by conseguence) store on the database.

I hope I've been clear. Thank you.
Back to top
View user's profile Send private message Visit poster's website
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Tue Jan 27, 2009 6:11 am    Post subject: howto calculate value in subform whithout macros Reply with quote

Hello

I do describe two methods for your problem. The first method is use a query for calculating the total value when you need it.

The second methode is use the power of OOo. Using the power of OOo means most of the time use a subform. A subform acts like a query. In this case you can really use a query there you have only a value. A subform is bound to the parent form with fields who must have the same value. In the part problem I describe that you will not get the new value in the subform if you have change the parent form. For that reason I add a pushbutton. In this way you need no macro.

Methode 1
I think there is no reason to make a field "total" in your table. If you need the value "total" then make a query where you calculate the value.

select "id",
"euro/kg",
"kg"
"euro/kg"* "kg" as "total"
from "name of your table"

Null value give no problem in this case but sometimes a null can give problems.
A null value means not zero but means that it is not defined.


Methode2
If you want have the value of "total" the same time.
If you choose for this possibllity then it will be more complicated.
We can talk about the word form as a writer document and what you see in the form naviagator.
open the form(writer) in edit mode.
Open the form navigator
add a subform in the main form
make a control for the total value there
the base for the subform is a query:select "id","euro/kg"* "kg" as "total" from "name of your table"
choose for the master and the slave fields the the good fields.

Test first if you get the good values for the records you have.


Problem
If you make a new record or edit an existing record then the value "total" will not been displayed. An easy solution for this is make a button in the subform and with that pushbutton you can refresh the subform.If the main form changed and you push the button then you will be asked if the record must be saved. If you have answer the question then the new value will be displayed.

I hope this is clear. But I will try answer other question if you have them.
Study the tutorial from benitez
http://www.geocities.com/rbenitez22

other manuals
http://sheepdogguides.com/fdb/fdb1main.htm

I hope this helps you. Until I wrote this it was not clear to me that it was so easy. Villeroy and Voobase both try to make methodes to avoid macros and use more the power of OOo. I will try to follow them both

Romke
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group