Ignoring Null Values (1 Viewer)

k209310

Registered User.
Local time
Today, 02:29
Joined
Aug 14, 2002
Messages
185
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
 

simongallop

Registered User.
Local time
Today, 02:29
Joined
Oct 17, 2000
Messages
611
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
 

k209310

Registered User.
Local time
Today, 02:29
Joined
Aug 14, 2002
Messages
185
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
 

Mark Wild

Registered User.
Local time
Today, 02:29
Joined
Apr 9, 2003
Messages
126
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

Top Bottom