Link to home
Start Free TrialLog in
Avatar of Jay Williams
Jay Williams

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Jay Williams
Jay Williams

ASKER

Plenty there to chew on, guys.  Let me scratch my noggin.
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.
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.
These guys aren't just smart, they're generous and kind.