replace field with a calculated value

W

wgtubbs

In a form I have created a calculated field. I want that value to be
transfered to another field in my table using the ON CLICK event property of
the last field used in creating the calculated field. How do I do that?
 
B

Beetle

In most cases, calculated values should not be stored in tables. They should
be calculated in queries, or in unbound controls on forms/reports.
 
W

wgtubbs

I understand that. In this case I am creating a unique value that I want to
use as the primary key for the record I am creating. That is why I want to
put that calculated value into the key field.
 
B

Beetle

Maybe if you posted a little more info on what you are trying to do, and why,
someone could offer appropriate advice. On the surface, inserting a calculated
value into a new record as the PK would seem a bad idea, unless you are just
trying to auto increment a number or something like that. However, there are
always exceptions so maybe you have a unique situation. I just wouldn't
want to give out advice that could ultimately end up doing more harm than
good.
 
W

wgtubbs

Didn't mean to start a war. You are right. I should have included the
information on why I wanted to replace the field. I do have sound reasons on
why I want to do this. Maybe someone else can help. Thanks for the effort.
 
R

Rick Brandt

wgtubbs said:
In a form I have created a calculated field. I want that value to be
transfered to another field in my table using the ON CLICK event
property of the last field used in creating the calculated field. How
do I do that?

Me.SomeControl = Me.SomeOtherControl

Bad idea to use the Click event though. What if they Tab into the last
control rather than click on it? What if they never visit that control at
all? All such assignments should be done in the BeforeUpdate event of the
form.

Beyond that storing a calculated value is almost never a good idea. You
should be able to make a composite Primary Key from the combination of the
other fields. PKs consisting of multiple pieces of data crammed into one
field are generally frowned upon.
 
W

wgtubbs

Rick, Thanks a lot. Your answer provided the information I needed and moved
me in a different direction. I was able to solve the problem with your help.
 

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