Event Procedure not working

S

sonofroy

I have a form with 2 fields

Amount1
Amount2

What I am trying to accomplish is when you fill in Amount1, Amount 2 will
automatically be 80% of the value of amount1

My code for Amount2 is =[Amount1]*.8

every event I have tried has produced nothing for Amount2. Any ideas where I
should put this to get Amount2 code to work? Thanks
 
K

Keith Wilby

sonofroy said:
I have a form with 2 fields

Amount1
Amount2

What I am trying to accomplish is when you fill in Amount1, Amount 2 will
automatically be 80% of the value of amount1

My code for Amount2 is =[Amount1]*.8

every event I have tried has produced nothing for Amount2. Any ideas where
I
should put this to get Amount2 code to work? Thanks

You should calculate this value in a query. You should not store
calculations.

Keith.
www.keithwilby.co.uk
 
D

Daryl S

SonOfRoy -

Put your code in the BeforeUpdate event of Amount1. The code should be
Me.Amount2 is =Me.Amount1*.8
 
L

Linq Adams via AccessMonster.com

Actually, if done in code, it usually is placed in the AfterUpdate event of
the textbox, but it really is better to have this occur as a calculated event
in a Query, as Keith said. It shouldn't be stored, as stated, and having in
calculated in the Query also makes it available to reports.
 
S

sonofroy

That did not work it did not reutrn anything


Daryl S said:
SonOfRoy -

Put your code in the BeforeUpdate event of Amount1. The code should be
Me.Amount2 is =Me.Amount1*.8
--
Daryl S


sonofroy said:
I have a form with 2 fields

Amount1
Amount2

What I am trying to accomplish is when you fill in Amount1, Amount 2 will
automatically be 80% of the value of amount1

My code for Amount2 is =[Amount1]*.8

every event I have tried has produced nothing for Amount2. Any ideas where I
should put this to get Amount2 code to work? Thanks
 
S

sonofroy

Ok but then how do I return this value to the forms table?

Keith Wilby said:
sonofroy said:
I have a form with 2 fields

Amount1
Amount2

What I am trying to accomplish is when you fill in Amount1, Amount 2 will
automatically be 80% of the value of amount1

My code for Amount2 is =[Amount1]*.8

every event I have tried has produced nothing for Amount2. Any ideas where
I
should put this to get Amount2 code to work? Thanks

You should calculate this value in a query. You should not store
calculations.

Keith.
www.keithwilby.co.uk

.
 
J

J_Goddard via AccessMonster.com

Hi -

The after update event for [amount1] has 1 line of code:

Me!Amount2 = me![amount1] * 0.8

Note that this will fire only after you type a value in to Amount1.

If you want [amount2] to be calculated each time you go to a new record, then
you need to put the same code in to the On current event of the form as well.

If [amount2] is something you don't want to be able to change by typing in
that textbox, you can set the "locked" property of the textbox to Yes.

HTH

John


That did not work it did not reutrn anything
SonOfRoy -
[quoted text clipped - 13 lines]
 
K

Keith Wilby

sonofroy said:
Ok but then how do I return this value to the forms table?

A form can be bound to a query as well as a table. Create a query
containing the calculated field and bind your form to it. You *do not*
store the value in any table, it is calculated evry time the query is run.

Keith.
www.keithwilby.co.uk
 
L

Larry Linson

You've been advised about not storing a calculated value. However, you don't
say anything about whether or not the Amount2 control is bound, so it could
be you just want to do a Calculated Control. In that case, you could set the
Control Source for Amount2 to =Amount1*.8, and in the AfterUpdate event of
the Amount1 control, use Me.Amount2.Requery.

Larry Linson
Microsoft Office Access MVP
 

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