The If Statement will never be true (it will always run the else) because the trim function returns a string. Period. (Actually, that's only partly true, it returns a Variant of subtype String, but for all intents and purposes, it's a string). Since it returns a string, isnull will never return true, because even if there is nothing in the passed value, trim will then return an empty string (not a null string) and therefore, won't be null.... so, I figured I'd remove the trim statement. Still wouldn't return true for me.... then I realized that you declare the variable in the header of the function as a string.... which, automagically (when created) makes it an empty string. Even if you pass it a null value.
The final solution I found (after trying a myriad of other things) was to change the type declaration to a variant in the function header, and to pass it "null" (not vbnullstring (which is a string), and not vbnull (which is a long)). This successfully returned a true from that if block. Here is how I modified the code:
Public Function Field2Str(strValue As Variant) As String
If IsNull(strValue) Then
Field2Str = " "
Field2Str = Trim(strValue)
and I called it like this retval = Field2Str(Null) . I'd also like to point out that your function doesn't return an empty sting if the value is null, it actually returns space. In order to return an empty string you'd have to return "". Let me know if this has helped some...
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...