I get the error Saying
"Invalid Use of Null"
My code for Checking Null value is
VB Code:
IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage, "'", "")))
Is something wrong in the code...
Thanks
Printable View
I get the error Saying
"Invalid Use of Null"
My code for Checking Null value is
VB Code:
IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage, "'", "")))
Is something wrong in the code...
Thanks
VB Code:
IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage), "'", ""))
Hi Shakti,
if a remove the last bracket i.e ")" it gives a complie error sayingQuote:
Originally Posted by shakti5385
"argumetn not optional "
and the replace function is higlighted
Replace() function must be in the same format you had it in post #1:VB Code:
Replace[COLOR=Red]([/COLOR][I][expression][/I], [I][find][/I], [I][replace][/I][COLOR=Red])[/COLOR]
Is this code wrong ??
VB Code:
IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage, "'", "")))
Or am i missing out something...
IIF always Returns 2nd or 3rd parameter, depending on the condition in the first parameter, if this condition is True it returns 2nd parameter, else it returns 3rd parameter. But here you are not using the returned string, thats the error. Do something like:
VB Code:
Dim a As String a = IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage, "'", "")))
aside from the need as assign the value as jcis pointed out - the error is because both the second and third conditions are evaluated, regardless of the first - so if rs!replyMessage is indeed Null, VB still attempts to do the replace, and you get the error.
You shouldn't use the IIf construct, it's really slow (and in this case not need), the following would suffice:VB Code:
Dim a As String a = Trim$(Replace(rs!replyMessage & "", "'", vbNullString))
Tried using
VB Code:
Dim a As String a = IIf(IsNull(rs!replyMessage), "", Trim(Replace(rs!replyMessage, "'", "")))
still the same error
Hi Bush,Quote:
Originally Posted by bushmobile
Does this check for Null values ??
try thisVB Code:
IIf(IsNull(rs!replyMessage), "", Trim(Replace((rs!replyMessage & ""), "'", "")))
if it's null it'll return ""Quote:
Originally Posted by Kuamr
Both Methods Work!!!
Thank you Bush
Thank You Ganesh