How can I update one table with values from another

Ben2k

Board Regular
Joined
Oct 16, 2002
Messages
77
Okay, I have two tables,

Cars
VsVehicles

Cars has various fields but the two we are interested in are [Stock Number] and [Chassis]

VsVehicles also has a lot of fields including [ID] and [VIN]

What I want to do is hit a button and access goes through the cars table and posts [Cars.Chassis] into the [VsVehicles.VIN] field on the vehicles table.

Can anyone help me?

Ben
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi Ben2k,

Create a new query, add the two tables (with the link), Query -> Update.

Field 1 of the query = VIN from the VsVehicles table
In the "Update To" section, enter [Chassis]
In the Criteria section, enter Is Null

Save and Run

Late edit : and if you want to run this when the user presses a button, you can create a "button" on your form, and via a macro set this query to run when the button is clicked.

Note : this assumes you want to update the VIN number for vehicles that don't have one, as opposed to changing the VIN for all vehicles. If you do want to change the VIN for all vehicles then remove the "Is Null" part.

HTH, Andrew. :)
 
Upvote 0
The best way to do this is with an Update query.
1. Build a query with the 2 tables. Create a link on the table schemas from ID to Stock Number. Place the ID, Chassis and VIN fields in the grid.
2. Still in design view, select Update Query from the Query menu.
3. A new row appears in the grid. In the Update cell for [VIN], type [Chassis]
To run, hit the Run (exclamation mark) button.
Save the query.

In future, double-click the query icon to run the update. Say YES when Access asks you about modifying records.

Denis
 
Upvote 0
Thanks

When I run it I get an error message

"Record(s) cannot be edited; no update permissions on vsvehicles"

I should have said that vsvehicles is a linked table from another database, If I open that database directly I can edit the table no problem.

How can I fix this?

Ben
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,132
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top