Update Query Help

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
I’m new to Access and in the process of creating a database that is populated via Excel. I’ve created a linked Excel table and Access table. Then created an Append Query to do the updating. The Query updates the table in blocks of 50 records daily. This works perfectly.

I now need to create an Update Query. Creating the Query is straight forward enough. But on a daily basis I receive information that needs to be amended. My problem is updating one figure without wiping the whole record.

I know I need to write the formula in the field part. In Excel, the formula would be: =IF(A1<>"",1,2)

Any pointers would be much appreciated.
 
Take it in steps.

Start with a simple SELECT query and work on setting your criteria to make sure it is selecting the correct records for updating (do not worry about fields you are updating yet, just get the record selection (criteria) used in determining which records need updating.

Once you have that piece working, then you can work on which fields you want to update. From there, you might have to use IIF statements. For example, if a condition is met, update the value to something else, otherwise, just return itself.

Another option would be to have ten different Update queries, one for each field. You could then create a macro you can run all 10 with a single click instead of running each one manually.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I'm getting closer!

I followed you directions and have moved a little closer the solving my problem. I made a Select Query and worte the following formula's:

FieldA: IIf([Table2].[Colour] Is Not Null,[Table2].[Colour],[Table1].[Colour])
FieldB: IIf([Table2].[Amount]>0,[Table2].[Amount],[Table1].[Amount])

As the fiedls are Text and Number. I changed the formula to suit. These both work perfectly but when I convert the Query to an Update Query, enter the Update to: [Table2].[Colour] & [Table2].[Amount]. It says that the formulas are not a valid name and that I should check if teh punctuation and characters are correct.

I'm getting closer I think.
 
Upvote 0
Sorry, I was away for a few days.

The IIF part of the clause will be your criteria, and then the THEN part will be in the UPDATE TO line (just the one that changes). I would recommend doing just one field update at a time, at least initially until you got it working.

If you are still having trouble post back.
 
Upvote 0
Thanks for your reply.

I now have it working. I entered:

IIf(IsNull([Table2].[Field]),[Table1].[Field],[Table2].[Field])

Into the Update To part of the query, obviously changing the field name to suit. Thanks for your pointers, patience and time. It's much appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top