Avoiding errors caused by Null value

Invalid Use Of Null sometimes becomes one of the biggest banes of programming in Access Basic. It is one of the most persistent and irritating errors encountered while developing an MS Access application. You might want to compare the values of two variables and the code bombs as one of the variables contains a Null value...There are two ways in which you can handle this error:

Function NulltoZero(varParam as variant)
On Error Resume Next
If isNull(varParam) Then
	NulltoZero = 0
Else
	NulltoZero = varParam
End if
End Function

This alternative has its own overheads of executing the function and then dealing with the zero it returns.

OR

If Not MyVar & "" >= YourVar & "" then
	<Action statements>
End If

 

Back to MS Access Tips

Perfect Paradigm - A Solutions Company