&Quot;If Then, Else" Fix

Microsoft has identified a problem you may experience with Access 2000. The problem occurs when Access 2000 improperly evaluates an If Then Else expression comparing a variable that is null. Microsoft's solution is to use IsNull() check on variables in the If Then Else expression. Rewrite the expression to include IsNull(), as in the following example from Microsoft.

The expression below will not evaluate properly if strName or txtName is Null.

If strName = txtName then
strName = '1'
Else
strName = '2'
End if

Change the expression as follows to fix this minor bug:

If strName = txtName and Not IsNull(strName) and Not IsNull(txtName) then
strName = '1'
Else
strName = '2'
End if

Be sure to add the Not IsNull() function to your conditional clauses to eliminate errors.

This tip is extracted from Tipworld. For more tips on many other things visit their site called TipWorld.
home button   Just click on the button for the Tiproom's Home Page.
Date of last revision: 17 August 2001.