autofill values from one table to another

  • Thread starter Thread starter Radhika
  • Start date Start date
R

Radhika

The database I am working on has two tables of concern, 'tbl_NewInfo' and
'tbl_FollowUp'. There is a field called 'Injection' in both 'tbl_Followup'
and 'tbl_NewInfo'. I want the values in the field 'Injection' to
automatically get added to the same filed in 'tbl_Followup' when added to
'tbl_NewInfo'. How can i do this?
 
The database I am working on has two tables of concern, 'tbl_NewInfo' and
'tbl_FollowUp'. There is a field called 'Injection' in both 'tbl_Followup'
and 'tbl_NewInfo'. I want the values in the field 'Injection' to
automatically get added to the same filed in 'tbl_Followup' when added to
'tbl_NewInfo'. How can i do this?

Well... as a rule, you needn't and shouldn't! Data should be stored once only;
if tbl_Followup actually records information about followups (other than the
Injection), then you should add that data at the time that you have followup
information to insert, not before.

How are the two tables related? What is the primary key of each? What is the
meaning of the Injection field and why does it need to be in both tables?
 
The field was originally in tbl_Followup and that is why it is there. I have
now been requested to move that field to tbl_NewInfo. The only reason I want
to autofill is so that i do not have to copy and paste the value for
'Injection' for each record from one table to another. The primary field in
'tbl_NewInfo' is ID# and the primary fields in 'tbl_Followup' are 'ID#' and
'Date'. They are related by 'ID#' and there is a one to many relationship
between 'tbl_NewInfo' and 'tbl_Followup'.
 
They are linked by a primary filed, 'ID#' present in both the table. There is
a one-to-many relationship between 'tbl_NewInfo'(one) and
'tbl_Followup'(many).
 
The field was originally in tbl_Followup and that is why it is there. I have
now been requested to move that field to tbl_NewInfo. The only reason I want
to autofill is so that i do not have to copy and paste the value for
'Injection' for each record from one table to another. The primary field in
'tbl_NewInfo' is ID# and the primary fields in 'tbl_Followup' are 'ID#' and
'Date'. They are related by 'ID#' and there is a one to many relationship
between 'tbl_NewInfo' and 'tbl_Followup'.

This sounds like it should be a one-time update query, but if you need to do
it repeatedly:

UPDATE tbl_FollowUp INNER JOIN tbl_NewInfo
ON tbl_FollowUp.[ID#] = tbl_NewData.[ID#]
SET tbl_Followup.Injection = tbl_NewData.Injection
WHERE tbl_FollowUp.Injection IS NULL;

can be run as many times as needed. It will only copy those records which have
no data in tbl_FollowUp.
 

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

Back
Top