Passing calculated text box to a record text box

G

gumby

I would like to be able to pass a calculated text box to a record.

Record Field is CountPar

Text Field is SumCountPar. This field sums several other fields from a
subform. I want this value placed in a record on the main form. I have
tried default value, but no luck. I need it to be a field with a number
format.

Thanks,
David
 
T

tina

there's more to this idea than just setting the value of a field in the
form's RecordSource. you have to decide under what circumstances you want
this to happen and/or under what circumstances you *don't* want it to
happen. then you must choose the apropriate form and/or subform events to
run the code from and what validation you may need to apply to make it
happen only when it should. then you must ensure that it happens the way you
it to EVERY time, including handling code failures, and have a method in
place to verify the calculated values in the table records - in case an of
unforeseen and/or unrecognized failure occurrs at some point - or run the
risk of working with invalid data that you don't know is invalid.

all of the above issues make a good case for the normalization rule that
says you don't store calculated values in tables. instead, you calculate
those values from stored raw data, on the fly, whenever you need them.

hth
 
J

John Vinson

I would like to be able to pass a calculated text box to a record.

Record Field is CountPar

Text Field is SumCountPar. This field sums several other fields from a
subform. I want this value placed in a record on the main form. I have
tried default value, but no luck. I need it to be a field with a number
format.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

If you REALLY want to do it anyway (say, you want to use the
calculated value as a default which can legitimately be edited, e.g.
you're cheating at golf), you'll need to use the Form's BeforeUpdate
event to copy the value from an unbound calculated field into a bound
control.

John W. Vinson[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