recalculating values in a subform

R

ronytimm

I have a subform where price, quantity and discount are entered and then
total net value is calculated. I have tried everything but the recalculation
does not happen automatically when these values (or one of these values) is
entered or changed. I call a requery to update the data in the underlying
table, and have linked this query to several event property (on change, after
update, etc...) but it simply doesn't work. I have now added a button on the
form to "recalculate" and that works, but I would prefer if the recalculation
would happen immediatly and automatically.

can someone pls advice pls?
thnx
 
D

Darrell Childress

If everything is working as you'd like when you hit the "recalculate"
button, but you just don't want to have to hit the button and have it
happen automatically, you could simply enter code that says Me.Requery
in the After Update event of the price, quantity, and discount fields.
 
R

ronytimm

Darell,

OK, I see what you mean, but how do I set the code. Just copy from the
select statement in the query, which is
UPDATE Offerte_Detail SET Offerte_Detail.Detail_Nettolijn =
(([Detail_aantal]*[Detail_Eenheidsprijs]))*(1-[Detail_Korting]/100);

If I enter this I get an error in VB. I assume I need to set different
paranthis and allocades. Does the me.requery com after the statement or
before?

Sorry, not very experienced in this... thnx
 
D

Darrell Childress

If you want to put the code in the After Update Event, it would be
something like:

Me.NetTotal = Me.Detail_aantal* Me.Detail_Eenheidsprijs *
(1-Me.Detail_Korting)/100
***change NetTotal to whatever is the field name of your field that
shows the total.

If you do this, you would not need to do the requery (someone may want
to verify this, I'm not an expert)
Darell,

OK, I see what you mean, but how do I set the code. Just copy from the
select statement in the query, which is
UPDATE Offerte_Detail SET Offerte_Detail.Detail_Nettolijn =
(([Detail_aantal]*[Detail_Eenheidsprijs]))*(1-[Detail_Korting]/100);

If I enter this I get an error in VB. I assume I need to set different
paranthis and allocades. Does the me.requery com after the statement or
before?

Sorry, not very experienced in this... thnx


Darrell Childress said:
If everything is working as you'd like when you hit the "recalculate"
button, but you just don't want to have to hit the button and have it
happen automatically, you could simply enter code that says Me.Requery
in the After Update event of the price, quantity, and discount fields.
 
R

ronytimm

works like a charm. Thnx!!

Darrell Childress said:
If you want to put the code in the After Update Event, it would be
something like:

Me.NetTotal = Me.Detail_aantal* Me.Detail_Eenheidsprijs *
(1-Me.Detail_Korting)/100
***change NetTotal to whatever is the field name of your field that
shows the total.

If you do this, you would not need to do the requery (someone may want
to verify this, I'm not an expert)
Darell,

OK, I see what you mean, but how do I set the code. Just copy from the
select statement in the query, which is
UPDATE Offerte_Detail SET Offerte_Detail.Detail_Nettolijn =
(([Detail_aantal]*[Detail_Eenheidsprijs]))*(1-[Detail_Korting]/100);

If I enter this I get an error in VB. I assume I need to set different
paranthis and allocades. Does the me.requery com after the statement or
before?

Sorry, not very experienced in this... thnx


Darrell Childress said:
If everything is working as you'd like when you hit the "recalculate"
button, but you just don't want to have to hit the button and have it
happen automatically, you could simply enter code that says Me.Requery
in the After Update event of the price, quantity, and discount fields.

ronytimm wrote:
I have a subform where price, quantity and discount are entered and then
total net value is calculated. I have tried everything but the recalculation
does not happen automatically when these values (or one of these values) is
entered or changed. I call a requery to update the data in the underlying
table, and have linked this query to several event property (on change, after
update, etc...) but it simply doesn't work. I have now added a button on the
form to "recalculate" and that works, but I would prefer if the recalculation
would happen immediatly and automatically.

can someone pls advice pls?
thnx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top