home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,016 of 10,840   
   Ralph to Raoul Watson   
   Re: Puzzling "isNull" failing   
   15 Apr 06 09:09:34   
   
   From: nt_consulting64@yahoo.com   
      
   "Raoul Watson"  wrote in message   
   news:DTY%f.715$UK5.619@trndny01...   
   > I have used isNull statement for as long as I have used VB..   
   >   
   > Recently I am devugging a program and it is very clear that the "IsNull"   
   > function sometimes would return a true even when the value is not Null.   
   Any   
   > wild shot or theory as to why this is happening is appreciated. Also, any   
   > other alternative is appreciated since I am stuck and cannot proceed   
   without   
   > fixing this issue (tried = Null and that doesn't work either).   
   >   
   > Basically, I have a field in a databsse which could be null, so in the   
   code   
   > i have:   
   >   
   > ' mfld(x) would have field names like "NAME" etc.   
   >   
   >     If IsNull(datPrimaryRS.Recordset(mfld(x))) Then   
   >        fvalue = ""   
   >     Else   
   >        fvalue = datPrimaryRS.Recordset(mfld(x))   
   >     End If   
   >   
   > I have verified by stepping that isNull is true while moving the cursor   
   > shows   
   > "Steven Moss" in datPrimaryRS.Recordset(mfld(x))   
   >   
   > What gives?   
   >   
      
   That is strange.   
      
   The situation where IsNull fails with 'Empty' is well-documented. (ie, some   
   databases will reset a field (text, nullable) that once had a value back to   
   Empty or " ", and not Null when the value is deleted), and other issues.   
      
   But I have never encountered the situation were a value existed and IsNull   
   failed. However, the Field.Values in a Recordset collection are Variants and   
   occasionally a strange dance (or joint psychosis) can develop based on the   
   Field data type attributes, the SQL used to fetch the data, and whether you   
   have previous dereferenced the value in your code.   
      
   You might go back and see if you can find something unusual about this   
   particular Field and its history.   
      
   There is simple workaround in this case. Use this instead...   
           fvalue = datPrimaryRS.Recordset(mfld(x)) & ""   
      
   hth   
   -ralph   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca