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 Query Criteria

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hello

I am using Access 2003.

I have a database that is updated monthly with new data. But because there could have been corrections to data from previous months, I want to overwrite records in the current database if they've been updated in the new data and leave others as is (so not entirely wiping out the table first).

Ideally I want to create a button to import "new" data to a temporary table and then run an update query with the new database to the old.

The problem is that I've searched for awhile on how to use update queries and can't figure it out. Both tables are an exact mirror of each other with 27 columns. The unique identifier is a combination of two fields: chartnumber and account number.

Can anyone please point me in the right direction or even tell me if this is the right approach? Thanks very much.
 
UPDATE yourTable AS O RIGHT JOIN yourTempTable AS N ON O.chartnumber = N.chartnumber AND O.[account number] = N.[account number]
SET O.chartnumber = N.chartnumber, O.[account number] = N.[account number], O.SomeField = N.SomeField, O.AnotherField = N.AnotherField

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top