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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Append Query?

Status
Not open for further replies.

MajP

Technical User
Aug 27, 2005
9,382
US
Currently I do something like the following in code, but was wondering if it can by done through just an action query? I have tblEquipment which has information on pieces of equipment, and I have tblCharacteristics which has characteristics that are required to describe a piece of equipment. For example if the piece of equipment is a vehicle I might need top speed, mile per gallon, seating capacity. If it is a rifle i need characteristics like muzzle velocity, range, round per minute.

When I add a new piece of equipment I base it on a similar piece of equipment. I make a copy of all the characterics of a car in tblCharacteristics, change the equipment foriegn key to equal the primary key of my new piece of equipment, and clear the characteristice value. Here is an example

tblEquipment

equipmentID equipmentName
1 Car One
2 Rifle One


tblCharacteristics

equipmentForiegnKey characteristicName characteristicVal
1 Speed 100mph
1 Fuel Efficiency 20 mpg
1 seating capacity 5
2 range 500 m
2 Firing Rate 100 rounds/min

Now If I add a new car, I have an interface to say that it is like item 1. The code copies the characteristics from item i and copies those characteristics back into tblCharacteristics. It thens changes the foriegn key to the new equipment ID. It also clears out the characteristic value. In other words it adds the following to tblCharacteristics:

equipmentForiegnKey characteristicName characteristicVal
3 Speed
3 Fuel Efficiency
3 seating capacity

The user now has the appropriate characteristics and just needs to fill in the values.

So my question is can I write a combination Append and Update query that appends the selected characteristics, and updates the foriegn key (and other fields)for those characteristics. What is the syntax for a conbination update append?
 
Something like this ?
strSQL = "INSERT INTO tblCharacteristics (equipmentForiegnKey,characteristicName)" _
& " SELECT " & New_equipmentID & ",characteristicName FROM tblCharacteristics" _
& " WHERE equipmentForiegnKey=" & Old_equipmentID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. Seems almost to easy. I will try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top