How to make form populate table

Rich_B

Access Newbie
Local time
Today, 17:10
Joined
Feb 12, 2016
Messages
50
Hi

How do I get the data in a form control to populate the corresponding table field when the control source box already contains an expression for making calculations within the form?

Thank you
 
remove the expression from control source, instead put the expression on Default Value property. you must edit the record for it to be saved.
 
remove the expression from control source, instead put the expression on Default Value property. you must edit the record for it to be saved.

When I do this the expression doesn't populate the cells with anything.
 
ok on the after update event of your controls:

private sub controlName_AfterUpdate()
me.yourtextboxwithExpression = expression
end sub
 
ok on the after update event of your controls:

private sub controlName_AfterUpdate()
me.yourtextboxwithExpression = expression
end sub

Does this look correct?

Private Sub WEIGHT_AfterUpdate()

Me.WEIGHT = IIf([WEIGHT CALC] <> "0", ([H] * [W] * [L] * [WEIGHT CALC] / 1000000000), "-")

End Sub

WEIGHT is the name of the textbox

Thank you
 
yes, do it also to the rest of your control's after update (if you have, ie H, L, W).
wait, you cant do arithmetics with string:

Me.WEIGHT = IIf([WEIGHT CALC] <> "0", ([H] * [W] * [L] * [WEIGHT CALC] / 1000000000), "-")

should be:

Me.WEIGHT = IIf([WEIGHT CALC] <> 0, ([H] * [W] * [L] * [WEIGHT CALC] / 1000000000), "-")

or:

Me.WEIGHT = IIf(Val([WEIGHT CALC] & "")<> 0, ([H] * [W] * [L] * [WEIGHT CALC] / 1000000000), "-")
 
Last edited:
How do I get the data in a form control to populate the corresponding table field when the control source box already contains an expression for making calculations within the form?

ALARM BELL!

Do not do this. If you are calculating it at run-time, you always calculate it at run-time. This is part and parcel of database design in that you do not store calculated values. (See: normalisation.)

Quick reason why: If you have a field called Quantity and a record's value is 2 and you have another field called Price and it's value is $2, then you do not have a third field called, say, Total Price, which stores the value of $4. Instead, you just multiply $2 by 2 every time you need to use it. If you stored the value, and then someone comes along and changes the quantity to 3, then you are still recording $4, when it should now be $6.

Take that simple example, and apply it to your predicament. You have all the values you need to calculate the end result. Just calculate it each time.
 
What Mile-O said! Rarely does a situation arise where it is appropriate to store a calculated value...and this is not one of those situations!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom