Recalculate a field when another field's value changes - JCW


J

JohnW

I have the following fields I'm working with; they are all on the same Form
which comes from a query.

MultiClassDisc
TotalTuitions

TotalTuitions is calculated by the sum of (4) other Tuition fields. I have
a check box to trigger the calculation of the MultiClassDisc field which
works off of the following code.

If MultiClass.Value = vbTrue Then
MultiClassDisc.Value = TotalTuitions * 0.1
Else
MultiClassDisc.Value = 0
End If

It works Ok.....when I check the box it calculates MultiClassDisc to be 10%
of the TotalTuitions and when I click the box off it changes the value back
to zero.

The issue I need help with is that the TotalTuitions value will change
sometimes and when it does if the box is checked the MultiClassDisc field
will not change automatically to reflect the new 10% value. If I uncheck the
box and then re-check it will show the new value but obviously I need it to
work automatically.

Any suggestions? Thank you
 
Ad

Advertisements

J

JohnW

Marshall

Unfortunately the MultiClassDisc field will be changed from time to time.
That's why I wanted to use the checkbox and the code to be able to turn it
off and on as needed.
 
Ad

Advertisements

B

Bob Barrows

JohnW said:
I have the following fields I'm working with; they are all on the
same Form which comes from a query.

MultiClassDisc
TotalTuitions

TotalTuitions is calculated by the sum of (4) other Tuition fields.
I have a check box to trigger the calculation of the MultiClassDisc
field which works off of the following code.

If MultiClass.Value = vbTrue Then
MultiClassDisc.Value = TotalTuitions * 0.1
Else
MultiClassDisc.Value = 0
End If

It works Ok.....when I check the box it calculates MultiClassDisc to
be 10% of the TotalTuitions and when I click the box off it changes
the value back to zero.

The issue I need help with is that the TotalTuitions value will change
sometimes and when it does if the box is checked the MultiClassDisc
field will not change automatically to reflect the new 10% value. If
I uncheck the box and then re-check it will show the new value but
obviously I need it to work automatically.

Any suggestions? Thank you

Create an Onchange event handler for the TotalTuitions control. I would
suggest copying the above code into a new function in form's module, and
then calling the function from the event handler subs for both controls.
 

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