Copy Value to Field

G

GOL

I have two fields in a table. I have both these fields on a form for data
entry. For purposes of uploading to another database, there must be these
two fields with different names (named A and B) even though they contain
exactly the same data. What I would like is for when the data is put into
one field (either field A or B), the data automatically shows up in the other
field on the form, and therefore in the table also. Entering the data twice
is a waste of time and would like each field to "mirror" the other
automatically after data entry of one field on the form.
 
K

Ken Sheridan

Do you really need to duplicate the values? Doing so constitutes redundancy
and runs a high risk of update anomalies. Can you not base the export of the
data on a query which returns the same field twice, so if the field in the
table is called A you could use a query like this:

SELECT A, A AS B, <more fields>
FROM YourTableName;

To do this in query design view add the A column to the design grid in the
usual way then in the 'field' row of the next column enter B:A, then add the
other columns in the usual way.

Using a query like this to compute the duplicate column on the fly
eliminates any redundancy and guarantees no update anomalies. It could be
done in your form with two separate fields in the table by putting the
following in the AfterUpdate procedure of the control bound to the A field:

Me.B = Me.A

but I'd strongly advise against it.
 
J

John Vinson

I have two fields in a table. I have both these fields on a form for data
entry. For purposes of uploading to another database, there must be these
two fields with different names (named A and B) even though they contain
exactly the same data. What I would like is for when the data is put into
one field (either field A or B), the data automatically shows up in the other
field on the form, and therefore in the table also. Entering the data twice
is a waste of time and would like each field to "mirror" the other
automatically after data entry of one field on the form.

Alternative suggestion: rather than uploading from a Table, upload
from a Query with a calculated field:

B: [A]

This will simply duplicate the value in field A for export purposes
without having to store it redundantly (much less enter it twice).

John W. Vinson[MVP]
 
Top