How do I deal with null values in Access update queries?

I have imported ranges from Excel sheets that I need to use to update records in an Access table. The sheets go into a table identical to the one containing the records to be updated, including the key index ID (numbered, not autonumbered).  The recordset that is used to update has many null values in the records, sometimes all of the matching records may have ALL null values in every field. Here's my query sql:
UPDATE WorkingListT INNER JOIN PickListT ON WorkingListT.PID = PickListT.PID SET PickListT.Sloc = [WorkingListQ].[Sloc], PickListT.Priority = [WorkingListQ].[Priority], PickListT.DaysPastPickDate = [WorkingListQ].[DaysPastPickDate], PickListT.Pcs = [WorkingListQ].[Pcs], PickListT.Links = [WorkingListQ].[Links], PickListT.Reservation = [WorkingListQ].[Reservation], PickListT.ResOnly = [WorkingListQ].[ResOnly], PickListT.ClosedOnDate = [WorkingListQ].[ClosedOnDate], PickListT.WBS = [WorkingListQ].[WBS], PickListT.HXSlocInv = [WorkingListQ].[HXSlocInv], PickListT.SlocLineLocation1 = [WorkingListQ].[SlocLineLocation1], PickListT.SlocLineLocation2 = [WorkingListQ].[SlocLineLocation2], PickListT.SlocLineLocation3 = [WorkingListQ].[SlocLineLocation3], PickListT.LeadTimeDays = [WorkingListQ].[LeadTimeDays], PickListT.ResReassgnd = [WorkingListQ].[ResReassgnd], PickListT.Countdown = [WorkingListQ].[Countdown];

Open in new window

Pretty straightforward, but when I run it, I get a parameter error for every field.  I tried using the IIf statement in the criteria, but I can't seem to get the syntax right.  Any better ways around this? Any ideas?
Jay WilliamsOwnerAsked:
Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
So the "WorkingListQ" Table may contain null values? If so, need to determine what you want to do with them. If you want the "receiving" table to accept those Null values, then be sure your table columns are set to allow Null values.

You can also use the Nz function:

UPDATE WorkingListT INNER JOIN PickListT ON WorkingListT.PID = PickListT.PID SET PickListT.Sloc = Nz([WorkingListQ].[Sloc], ""), PickListT.Priority = Nz([WorkingListQ].[Priority],""), etc etc

Of course you'd need to set the "return" value of the Nz to a valid argument.
Dale FyeCommented:
Scott's comment "determine what you want to do with them" is critical.

If the destination table already has a value in that field, do you want to overwrite it with a NULL (in your source table), or do you want to keep the previous value if no new value is provided?  If you want to keep the previous value you could probably use syntax similar to:

NZ([WorkingListQ].Priority, PickListT.Priority)
Agree with Scott's comment.

I add use Nz([WorkingListQ].[Sloc]) to allow for different data types of corresponding field.

Use the same idea with other null expected fields.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jay WilliamsOwnerAuthor Commented:
Plenty there to chew on, guys.  Let me scratch my noggin.
Jay WilliamsOwnerAuthor Commented:
Yeah, there's something fundamental I'm not getting.  Tried all of your syntax, read the method support page; quotes, no quotes, same error. I think I get it conceptually, but still missing something.  Argh.
Jay WilliamsOwnerAuthor Commented:
Got it, men.  It's always something easy and stupid isn't it?  I fat-fingered the name of the table.  You were all right, and taught me a lesson (again) thank you.
Jay WilliamsOwnerAuthor Commented:
These guys aren't just smart, they're generous and kind.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.