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:
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?
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)
Hamed Nasr
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.
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.
Jay Williams
ASKER
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 Williams
ASKER
These guys aren't just smart, they're generous and kind.
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