|
-
Mar 21st, 2000, 07:06 PM
#1
Thread Starter
New Member
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
-
Mar 21st, 2000, 07:53 PM
#2
Junior Member
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
-
Mar 21st, 2000, 10:53 PM
#3
PowerPoster
iif function
you also can use the iif function like...
text1.text = iif(IsNull(.Field(0)),"",.Field(0))
-
Mar 21st, 2000, 11:01 PM
#4
Frenzied Member
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.
-
Mar 22nd, 2000, 05:40 AM
#5
Hyperactive Member
Another simple way is using the trim function:
Code:
Text1.Text = Trim("" & rs!Name)
Good Look!
Ulises Vázquez
[size=1.7]Oracle DBA Certified Professioanl
Visual Basic 6 Developer
Crystal Reports Designer
[/size]
-
Mar 23rd, 2000, 06:20 AM
#6
Addicted Member
you don't even have to use the trim:
Text1.Text = "" & rs!Name
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|