Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alter Table to Two Tables 1

Status
Not open for further replies.

joatmofn

Technical User
Jan 12, 2003
72
US
My tblWorkOrders table has a vehicleID field which is a lookup field to the tblVehicle table. It simply associates a truck number with the work order. This is fine for a one truck per work order job. Now we are assigning multiple trucks to one job/workOrder.

I created a table called tblWorkOrderTrucks and created a 1:M relationship from the tblWorkOrders table to the tblWorkOrderTrucks table. The link between the two tables is the WorkOrderID.

So, for each record in tblWorkOrders that has a truck assignment, I need to create a record in tblWorkOrderTrucks table. The created record will have three fields (ID, type autonumber, WorkOrderID, and VehicleID.

In other words, I need to copy the existing vehicleID and WorkOrderID from the tblWorkOrders table to the tblWorkOrderTrucks table but am not sure how to proceed. Update query, append query, combination of update & append query, vba,?

Just not sure about this, so any input would be appreciated.

Thanks.

 
This is a fairly simple INSERT query:

insert into tblWorkOrderTrucks (WorkOrderID, VehicleID)
select WorkOrderID, VehicleID
from tblWorkOrders

Just copy this and paste it into a query design SQL window, then run it. It assumes the table is currently empty.

John

 
I added a criteria to your query and that did the trick. Thanks a bunch - here's a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top