|
-
Jun 20th, 2000, 04:57 PM
#1
Thread Starter
Lively Member
If in Access 2000, I have a field a text field with no data inside. Then in VB6, when I assign that field to a text box, I get a error with 'Invalid use of null'. I have to place a if statement before the assign statement to make sure the field is not equal to "", only then I will assign it. This will prevent the error but it is very troublesome if I have about 20 to 30 field to check.
Is there any option or way that I can use without having checking for empty text field ? If it just an empty field, just assign a empty string to it.
Thanks
-
Jun 20th, 2000, 05:22 PM
#2
Lively Member
I have a little function, that does exactly what you want
Code:
Public Function Field_Empty(s) As String
If IsNull(s) Then
Field_Empty = ""
Else
Field_Empty = s
End If
End Function
you call the funtion this way:
Code:
Text1.Text = Field_Empty(Recordset!Fieldname)
Hope, this helps
-
Jun 20th, 2000, 05:33 PM
#3
Fanatic Member
Try the following instead of IF statements :
Code:
TextBox.Text = "" & rs!Field
Hope this helps
-
Jun 20th, 2000, 05:34 PM
#4
Addicted Member
You could set the Allow Zero length property of the fields to Yes in Access.
I usually assing values to strings by concatenating them to an empty string.
strString = "" & tblTable!Adress
or the other way round
tblTable!Adress = "" & Text1 before updating the record.
Regards,
Laurens
Using VB5 Enterprise edition SP3
VB6 Enterprise edition SP5
-
Jun 20th, 2000, 05:44 PM
#5
New Member
Im not 100% on this but it should work
In your database if you set the Default Value of your text fields to Null then VB should allow you to use VbNull when checking the field.
-
Jun 21st, 2000, 03:48 AM
#6
Thread Starter
Lively Member
Thanks for all the replies... My problem solved.
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
|