... I think smig is using the word "No Value" in the wrong context.it should be a strings, either declared variables or (as in most cases) fields from tables.
Based on what code and based on what value that was passed to it (as ChrisO has asked twice)?here is where you'r wrong vbaInet:
1. it's NOT Null, as I explained at first it's pass the IsNull() as false
2. it's NOT Zero-Length String (ZLS) as trim(string) = "" bring the error
3. it's NOT Empty as it's not variant
it is a NO VALUE
I'm trying to check data for Null or Empty.
tried to use the IsEmpty function but it return True for Null values
so I made my oun function:
normaly this code works OK.Code:Function NullOrEmpty(strTextToTest As Variant) As Boolean If IsNull(strTextToTest) Then NullOrEmpty = True Exit Function End If If Trim(strTextToTest) = "" Then NullOrEmpty = True Exit Function End If NullOrEmpty = False End Function
but I noticed that it might bring back an error:
2427 - you entered an expression that has no value
this error pop for the If Trim(strTextToTest) = "" Then
which mean it's not null.
how can I send a data with no value ?
Function NullOrEmpty(vntTextToTest As Variant) As Integer
NullOrEmpty = (Len(vnTextToTest[COLOR=Red][B] & ""[/B][/COLOR]) = 0)
End Function
Function NullOrEmpty(vntTextToTest As Variant) As Integer
NullOrEmpty = (Nz(vnTextToTest[B][COLOR=Red], ""[/COLOR][/B]) = "")
End Function
If IsError([Field]) Then
Debug.Print "Has No Value error"
Else
... do something else
End If
I find several nested IIFs to be hard to read.
If there is no logic in the nested IIF I tend not to use it.
If whatever Then
somestuff
ElseIf someothertest Then
someotherstuff
ElseIf anothertest Then
differentstuff
Else
whatever or nothing
End If
Exit Function
thank you all for the help
this session was a good learning for me.
I couldn't have it without all the help, tip, ideas and info I got here.