PDA

View Full Version : [SOLVED:] help with Multiple criteria for table update



werafa
09-18-2017, 02:32 AM
Hi all,
I'm sure this is a newbie question - my apologies in advance. I've searched around, but don't understand how to get this to work.
I can follow SQL and VBA, and am a rank beginner at Access

I wish to create a system for importing a table from excel and updating a master database with new/modified records from the imported table.
the records in each table can be matched using [Name] and [dDate] fields (this combo is unique)

I have a table (tbl_FromExcel) with my imported data. I wish to overwrite/update all data fields (assume fF1, fF2, fF3, and fF4 for this example) where records in the master database (WeeklyKPIs) differ and to create those that don't exist.

Is there a simple SQL based query command to do this?
Thanks
Werafa

jonh
09-18-2017, 03:46 AM
No simple command. Sorry. You need several queries to do the deletes, updates and appends.

OBP
09-18-2017, 04:59 AM
As Jonh says, it can't be done with one query.
It is possible with 2 queries providing you do not need to delete any records.
You need one Update query to update all the records in the Master table that match the imported table, if the data is the same it doesn't matter if it gets rewritten..
You need one Append query to append any records not already in the Master table.

werafa
09-19-2017, 02:24 AM
Thanks for that.

I think I have something like this working now - using the two query approach.
no delete is needed, and the idea is that even if the excel dataset is reset each fin year (it gets a bit big), the access database retains the history for reporting and analysis.

I'll post something once I've confirmed that it does work correctly.

werafa
10-02-2017, 01:03 PM
yes - it works
Thanks all