[AccessD] Update Query?

Gustav Brock gustav at cactus.dk
Wed Jun 2 12:10:52 CDT 2004


Hi Bridget

> I will be pulling  a table on a monthly basis from another access
> database. Initially, I make a new table with these records. Then monthly,
> I want to update the new table with only records that have changed from
> their original source or new records that have been added.

> Is this a simple query?

Not quite sure from your explanation what is "initial" and what is
not. However, a combined update/append query is possible - but you
need to type a little more than usual. 

Here tblOld is the table holding the old records (to be modified or
supplemented), while tblNew is the table holding the new or revised
records:

1. Create an update query and add the two tables. Join the two tables
by dragging the key field of tblNew onto the matching field of tblOld.

2. Double-click on the relationship and choose the join option that
includes all records from tblNew and only those that match from tblOld.

3. Select all the fields from tblOld and drag them onto the QBE grid.

4. For each field, in the Update To cell, type in tblNew!FieldName
where FieldName matches the field name of tblOld. 

5. Select Query Properties from the View menu and change Unique
Records to False. This switches off the DISTINCTROW option which you
otherwise will see in the SQL view of the query.
If DISTINCTROW is on you'll get only one blank record in your results,
but you want one blank record for each new record to be added to
tblOld. 

6. Run the query. When done, the changes from tblNew have been applied
to tblOld.

This will only add records to tblOld that existed in tblNew but not in
tblOld. No records will be deleted; records in tblOld that aren't
present in tblNew will remain untouched.

/gustav




More information about the AccessD mailing list