by Robert D. Payne (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 2nd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Duplicates the Nz function found in Access VBA to replace a NULL with a default value or object.
' returns ValueIfNull if Expression is null,
' returns zero if Expression is null and ValueIfNull is missing
' else returns Expression
'==============================================================
'example:
' With udtExistingRecord
' .RespCode = Trim(Nz(rsCreditCardData!RespCode, ""))
' .fErrors = Nz(rsCreditCardData!fErrors, 0)
' booErrors = Nz(rsCreditCardData!fErrors, 0)
' .Description = Trim(Nz(rsCreditCardData!Description, ""))
' .CardNum = Trim(Nz(rsCreditCardData!CardNum, ""))
' End With
'==============================================================
If Not IsMissing(ValueIfNull) Then
If IsNull(Expression) Or IsEmpty(Expression) Then
If IsObject(ValueIfNull) Then
Set Nz = ValueIfNull
Else
Nz = ValueIfNull
End If
Else
GoTo NotNull
End If
Else
If IsNull(Expression) Then
Nz = 0
Else
GoTo NotNull
End If
End If
Exit Function
NotNull:
If IsObject(Expression) Then
Set Nz = Expression
Else
Nz = Expression
End If
End Function
No comments have been posted about Duplicates the Nz function found in Access VBA to replace a NULL with a default value or object.. Why not be the first to post a comment about Duplicates the Nz function found in Access VBA to replace a NULL with a default value or object..