Click to See Complete Forum and Search --> : Invalid use of null
jcontract
Mar 21st, 2000, 06:06 PM
I'm trying to create a sample connection to the Nwind.mdb through code. All connections are fine until I encounter a record that has a blank field. I get an error as soon as I encounter this. Am I supposed to be coding for invalid use of null ? If so, could someone give an example ? TIA
browner
Mar 21st, 2000, 06:53 PM
text1.text = rs!Name & ""
if the rs!Name (or any other variable) is null then adding "" to it will make it a blank string instead.
or use IsNull(rs!Name) to check if it is null before trying to assign it to a textbox etc
Chris
Mar 21st, 2000, 09:53 PM
you also can use the iif function like...
text1.text = iif(IsNull(.Field(0)),"",.Field(0))
JHausmann
Mar 21st, 2000, 10:01 PM
IIF's should be used sparingly, if at all. They are slow, they always evaluate both conditions and if one side fails (even if it's not the side passing evaluation), the whole statement fails.
Tonatiuh
Mar 22nd, 2000, 04:40 AM
Another simple way is using the trim function:
Text1.Text = Trim("" & rs!Name)
Good Look!
pardede
Mar 23rd, 2000, 05:20 AM
you don't even have to use the trim:
Text1.Text = "" & rs!Name
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.