|
PROBLEM: I thought I had this resolved, but I am having trouble dealing with null values. Every time my function attempts to encrypt a null field within a record, I receive "#Error" in the query results for the encrypted field.
ATTEMPTS TO TEST FOR NULL FIELDS:
I am trying to test to see if strString, (the argument within the my function Encrypt) is null.
(FUNCTION PROTOTYPE:
Public Function Encrypt(strString As String) As String)
ATTEMPT#1:
'test to see if strString is null using null notation
If strString is null Then
intStrLength = 0
End If
RESULT: data type mismatch error at compile time.
ATTEMPT#2:
'test to see if strString is null using "" notation
If strString = "" Then
intStrLength = 0
End If
RESULT: no compile or runtime error messages, but "#Error" appears in the query results view.
ATTEMPT#3:
'test by measuring string length. If string length is not greater
'than zero, assign field length to zero
If intStrLength > 0 Then
intStrLength = intStrLength
Else
intStrLength = 0
End If
RESULT: no compile or runtime error messages, but "#Error" appears in the query results view.
OBSERVATION: The problem with using the len function appears to be that the function will not return the value zero when measuring the length of a null string. The len function simply fails to return any results.
Any thoughts would be appreciated.
|