Forum Discussion
What's the cleanest way to skip NULLs when looping through Recordest in VBA?
There are two components to the problem.
First, if your data has nulls scattered through different fields in different records, the way you handle that is pretty much what you are doing now, writing defensive code to handle those nulls.
Second, the a priori question is why does the data include nulls? Obviously, the process is such that you allow for them. However, it is sometimes the case that a better approach is to structure the data so that nulls are not allowed. Without knowing more about your particular business rules and data, it's not possible to be more specific, yet I'd be looking at whether you can avoid them in the first place.
And finally, instead of running your process directly on the table with nulls, perhaps you could first create a query to use Nz([FieldName], 0) or another appropriate Nz() expression to pre-handle the nulls before they are encountered in this recordset process.