-
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
-
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
-
Try the following instead of IF statements :
Code:
TextBox.Text = "" & rs!Field
Hope this helps :)
-
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.
-
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.
-
Thanks for all the replies... My problem solved.