Data Copying

P

PC nerd

How can i automatically copy a feild from one table and copy it into a
second, related table. Both feilds are primary keys.

eg. I use a form to input a value into the...customer_Code field in the
customer table, and as soon as i enter the data, i need it to auotmatically
place the same data inot the customer_Code field in the Agent Table.
 
S

Steve Schapel

PC nerd,

You could run an Append Query to add a new record to the Agents table
with the same customer_Code. For example, code like this on the After
Update event of the customer_Code control on your Customer form...

CurrentDb.Execute "INSERT INTO Agents ( customer_Code )" & _
" VALUES ('" & Me.customer_Code & "')",
dbFailOnError
' (assumes customer_Code is text data type)

It seems very strange that the same customer_Code is a primary key field
in both tables. Are you sure?
 
Top