Re: Update and Append Query
From: Tom Lake (tlake_at_twcny.rr.com)
Date: 11/10/04
- Next message: LauraB: "Between function ignores years, after performing date addition"
- Previous message: el zorro: "Re: Math Error in Query??"
- In reply to: John Ortt: "Re: Update and Append Query"
- Next in thread: John Ortt: "Re: Update and Append Query"
- Reply: John Ortt: "Re: Update and Append Query"
- Reply: Jamie Collins: "Re: Update and Append Query"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 9 Nov 2004 19:01:46 -0500
>> > You need two separate queries, an Update and an Append one. The trick
>> > is
>> > to
>> > use the right filter; the easiest way is to use a subquery in the
>> > criterion
>> > on the F6 field.
>>
>> No you don't. One query will do both.
>>
>> Tom Lake
>
> How would you do that then Tom? I have to confess I thought he would have
> to use two aswell.
> If it is possible with one query it would make some of my databases far
> tidier.
OK, lets say you have a Master and a Transaction table with Trans ID being
the PK in both. You want to add the day's transactions to the Master table
and modify any records that have changed throughout the day. You add the
Master table to an Update query, then add the Transaction table. Now drag a
line from the Trans ID in the Transaction table to the Trans ID in the
Master table. Make the join select all records from the Transaction table
so the arrowhead points to the Master table. This is called a right join
although the arrow will be pointing left if you added the tables to the
query in the order I specified. Now drag down all (or as many as you want
updated) the fields from the Master table to the grid. In the "Update To"
row add fields from the Transaction table. When you run this query, new
records will be added and existing records will be changed. It's that
simple. Here's my code:
UPDATE Master RIGHT JOIN [Transaction] ON Master.[Trans ID] =
Transaction.[Trans ID] SET Master.[Trans ID] = [Transaction].[Trans ID],
Master.Name = [Transaction].[Name], Master.DOB = [Transaction].[DOB];
Tom Lake
- Next message: LauraB: "Between function ignores years, after performing date addition"
- Previous message: el zorro: "Re: Math Error in Query??"
- In reply to: John Ortt: "Re: Update and Append Query"
- Next in thread: John Ortt: "Re: Update and Append Query"
- Reply: John Ortt: "Re: Update and Append Query"
- Reply: Jamie Collins: "Re: Update and Append Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|