Full Version: Copy Field Value to Another Field
UtterAccess Forums > Microsoft® Access > Access Forms
sclafani
I have a form with an unbound text field that concatenates the first_name and last_name fields (to make a firstname.lastname user ID).

How can I automatically copy this value to the user_id field?
ScottGem
Why would you want to? Why would you use a userID like that. What function does the userID perform?
sclafani
It is tied into the email address and a requirement of the system.
ScottGem
Ok, then construct it when you need to display the E-mail address. You don't need to store this since its a calculation.
[First_name] & "." & [Last_name] & "@domain.com"
Should give you the e-mail address.
sclafani
That much I have working. My problem is copying this value to another field.
created the formula in an unbound text field just like you said. But now I need to get this value into a bound field. How would I do this?
ScottGem
You aren't listen
Is a general rule we do NOT store calculated values. This is a calculated value. You have the components of the calculation so you use the expression wherever you need to display userID.
sclafani
I appreciate your trying to help me, but with all due respect I do in fact need to store this. I rather not get into explaing the entire system architecuture with you as the bottom line is that I need the result of this calculation in a specific field in a specific table. If you know how to copy this result to another field on the form please let me know.
ScottGem
With all due respect I can see no instance where you need to store this value. If you wish to explain why you think you need to, I can probably show you why you don't. If I find your explanation valid, I can show you how to do it. One of the things I like about UA is most of the "gurus" will not help foster design flaws in databases. If you are going to design it, do it right.
Is an example you state you need it in "a specific field in a specefic table". This would indicate, that you need to pull the value of the field in some routine. If you change that routine to pull the value from a query instead of the table, you can then add a column to the query using the expression. This would provide the EXACT same functionality as if the value were stored.
sclafani
Today users are manually typing in the First Name, Last Name, and Email Address. I'm trying to contruct email address so they don't have to type it. There is an existing vendor legacy program that pulls data from this email address field of this table. We can not change this program. That is why I say that it must be stored in this table. I understand your point about better design, but in this situation we are stuck with what we have.
ScottGem
Are you saying you can't change the object name that the Legacy program uses? Does the Legacy program actually connect to an Access database and table? Or does it import an exported file?
sclafani
Yes it connects directly to the Access DB. No, we can't change anything about the program (or more accurately, the vendor refuses to).
ScottGem
Refuses to?????? Ummm, you pay the vendor, they do what YOU want, not the other way around.
My there is a fairly simple way around this. Change the name of the table that the Legacy app connects to. Then create a query with the same name as the table. That query will pull all the fields from the renamed table and include a calculated column that has the ID. So now the legacy app will pull the data from the query instead of a table. The users will enter only the data they need to and data that should be calculated will be calculated and not stored.
motopsycho
Sorry to step in on this great debate, but I may be able to help with the original question. I had a similar question some time back.
heck out the link !
http://www.utteraccess.com/forums/showflat...0859&fpart=
HTH
Chris
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.