Command button on exit

M

Mike

Hi All,

I have a form "Loads" with a subform "Rating". In the subform I can change
things to make the toal charges change. I can't seem to save the total
charges as it changes though. I have to display the total in another text
box. My workaround on this was to assign the workaround box value to a
hidden contol on exit. That won't exit then. My next idea was to try it as
an after update event. The form didn't treat the new data as an update.

I made a command button to update the control that I want but now I need to
try to make that click on exit. I would make that an exit box with the
extra commands but it's a tabbed form and people may leave other ways.

Please help, I hope I haven't been too confusing or all over the place.

Mike
 
A

Arvin Meyer

It is against relational database normalization rules to save the results of
a calculation. There are exceptions, usually when a history is involved.
Generally if the elements of the calculation are stored the result need not
be since it can be recalculated at any time.

If you must store it, the most common method is to Push the data instead of
Pulling it. In each of the control, check that the other controls have a
value and then set the value of the final result. Something like (air code):

Sub txtControl1_AfterUpdate()
If Len(Me.txtControl2)>0 Then
Me.txtResult = Me.txtControl1*Me.txtControl2
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
M

Mike

Thanks for the quick response. I think the reason I am trying it this way
was because it picks this number from three possibilities based on 2 nested
If statements. Should I consider saving all three possibilities and a value
from the if statement?
 
A

Arvin Meyer

Consider this:

Never store the data that isn't used, but save the result of the calculation
only if it can't be calculated again.

For instance:

10 * $1 will always be $10 unless the $1 dollar can change (like the price
of gasoline)

If I was born on 8/13/1962, my age can always be calculated. No matter how
old I get, I'll never need to store my age.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Top