Copy record from one to another table by clicking checkbox (1 Viewer)

saledo2000

Registered User.
Local time
Today, 23:30
Joined
Jan 21, 2013
Messages
94
Hello everyone,
I've created checkbox in one form and would like to copy/populate data from one field to specific field in another table, to be able to link these two tables. The field name is CY-Code (e.g. CY-1000) from table "GENETIC" want to copy to "DNA samples" table, field name is the same CY-Code. Does anybody know how to write VB code for this procedure.

Thank you
 

DavidAtWork

Registered User.
Local time
Today, 23:30
Joined
Oct 25, 2011
Messages
699
How are these 2 tables joined, what are the linking ID's, also how does this checkbox work, is it supposed to indicate which records you want to update
David
 

saledo2000

Registered User.
Local time
Today, 23:30
Joined
Jan 21, 2013
Messages
94
They are not linked right now. In the form I have sub form with DNA sample code. To be able to link certain code to the specific DNA profile need to populate DNA samples table with CY-Code who represent missing person. Checkbox is called "Identified". Then this two tables will be linked to each other via CY-Code. Yes this checkbox works as you asked. Will populate CY-Code which is set when I open the form "GENETIC".

Thanks.
 

DavidAtWork

Registered User.
Local time
Today, 23:30
Joined
Oct 25, 2011
Messages
699
You're trying to update the field that links the 2 tables !!!!
I'd suggest you add a new field to table 1, call it NewCY-Code and populate records with the new values and then use an update query that updates all records in table 2

UPDATE [table 2] SET [CY-Code] = [table 1].NewCY-Code
FROM [table 1], [table 2]
WHERE [table 2].CY-Code = [table 1].CY-Code
David
 

saledo2000

Registered User.
Local time
Today, 23:30
Joined
Jan 21, 2013
Messages
94
Thanks David
I have created new field in the second table which is empty now. That field has the same name as the field in table GENETIC. I'll try tomorrow at work and let you know.

Thanks again.
 

Users who are viewing this thread

Top Bottom