View Full Version : Copying columns


mozinator
12-03-2004, 04:20 AM
Please help me, I'm really beginner in doing macros in access and I need a small one. I have to copy three first columns from table to another, there add one column with numbers and with that new column overwrite the three in the first table. I mean that it's not problem for some experience user. So can anyone help me how to do this? Some commands or so? Or some link where I can find some help? I will be very thankful for any help.

reclusivemonkey
12-03-2004, 07:31 AM
From what you describe, it sounds like you need to use an 'update query' to copy your columns from one table to another. You should not need to use macros to accomplish this.

mozinator
12-03-2004, 08:04 AM
But I want to do this automatically and I don't know how to do it with query?

gblack
12-09-2004, 12:11 PM
Sounds like you can do this without moving all those columns everywhere.

Open a query in design mode.
Choose the First table and the table from which you need those three columns.
Go to “query” and choose make table query. Give a new name for a new table you will be making.
Link the two tables via their primary key (assuming they can be linked and have a one to one relationship)

Now…I am assuming when you want a new column with numbers that this is a calculation based on the three columns that you want to move around.

So the first thing you want to do is drag all the columns you will want to end up with from the first table down to the grid.
Then in the next open column, you will make the new column with the calculations you wanted. I don’t know what your calcs are, but it should look something like this:

NewColumnName: ([column1]+[column2])/[column3]

So now when you run that query (hit the ! button), Access will make a new table which should have the end result that you need.

Once you have this, you can make a macro that runs this query when you need it. Use the open query command in the dropdown box of the of a new macro. Go down to the bottom and it will give you a dropdown box with a list of queries. Choose the query that you just made.

Hope this helps a bit.

Gary