View Full Version : Table Row transfer


rishi_375
01-02-2004, 02:54 AM
Hi,
I have two table in Test.MDB. First table name is Master and second table is MasterDetail. I want to copy all Master table row in to the MasterDetail table. It's like when user click on Transfer button it should start row transfer from one table to second table. How i do this task.
Thanks.

dcx693
01-02-2004, 06:17 AM
Use an append query to get all the rows into the detail table. You can specify some criteria in your append query if you don't really want all the rows to be transferred every time. Look up append queries in the Access online help.

As to how to use code behind a command button to append the records, you'll want some code like this:
(if you're using Access 97 with DAO)
CurrentDb.Execute "INSERT INTO MasterDetail SELECT Master.* FROM Master;"

If that command didn't work, you can try this version (for Access 2000+ with ADO):
CurrentProject.Connection.Execute "INSERT INTO MasterDetail SELECT Master.* FROM Master;"

Pat Hartman
01-02-2004, 12:46 PM
Why would you want to add "empty" rows to the detail table? If you are having a problem with a query that joins these two tables because it is only returning rows where there are entries in both tables, you can resolve the problem by changing the join type from INNER to LEFT. Using a Left join (or possibly a right, read the descriptions) will return all the rows from the left side table even if there are no matching rows in the right side table.