Ignoring Null Values

k209310

Registered User.
Local time
Today, 02:41
Joined
Aug 14, 2002
Messages
184
Hi

this is just a general question about updating tables from code.

I have a class which updates a table. The class gets its values from a function which gathers the values from a form.

If I leave one of the fields in the form blank i get an error message in the function to warn me of an invalid null. to get round this i add a line similar to..

If IsNull(.TextBox) then goto...

This solves the problem but I was wondering tho if there was another way of doing this such as a line of code that tells the function to ignore all nulls in the forms objects or do i need to add a line of code to tell the function to ignore each object.

Any advice is greatly recieved

Chris
 
Check in the table to see if Allow Zero Length has been set to No. If it has then change it to Yes. If that doesn't solve it then am not sure apart from using the If Isnull(me.txt1) then me.txt1="" end if.

HTH
 
Thanks for the reply Harry

I wasnt actually having any problems with the code i was just wonndering if there was a more elegant way of catching the nulls that was all.

Thanks anyway tho

Chris
 
If you go down a similar line to Harry's suggesttion, try

Code:
Dim ctl As Control

For Each ctl In Me.Controls
    If IsNull(ctl) Then
        ctl = ""
    End If
Next ctl
 

Users who are viewing this thread

Back
Top Bottom