Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba
Thread: Empty String

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Empty String
Murray 12.09.2006 00:35:01
Hi all,
I guess I am doing something wrong here and not really understanding what.
I have a bit of code that you look to seee if the field is empty and if
empty the assign it a string value.the code I am using is:

DIM CS as Sting
If Me![contract subform]!CSO.Value = "" Then
CS = "no CSO"
Else
CS = Me![contract subform]!CSO.Value
End If
The CSO Value is the Customer Service Officer, so if they have not put a
name in then a temp value is assigned otherwise the CSO is assigned to the
value.
When I run the code and the CSO.Value field is empty the code stops in the
Else statement saying invalid use of NULL
Can someone point me in the right direction?
Thanks
Re: Empty String
"Rick Brandt" <rickbrandt2[ at ]hotmail.com> 12.09.2006 00:43:38
"Murray" <Murray[ at ]discussions.microsoft.com> wrote in message
news:18340BC1-9B9F-4AC3-92A2-F8E99C120621[ at ]microsoft.com...
[Quoted Text]
> Hi all,
> I guess I am doing something wrong here and not really understanding what.
> I have a bit of code that you look to seee if the field is empty and if
> empty the assign it a string value.the code I am using is:
>
> DIM CS as Sting
> If Me![contract subform]!CSO.Value = "" Then
> CS = "no CSO"
> Else
> CS = Me![contract subform]!CSO.Value
> End If
> The CSO Value is the Customer Service Officer, so if they have not put a
> name in then a temp value is assigned otherwise the CSO is assigned to the
> value.
> When I run the code and the CSO.Value field is empty the code stops in the
> Else statement saying invalid use of NULL
> Can someone point me in the right direction?
> Thanks

If they haven't filled out the field then it is Null which is not the same as
"". CS cannot be assigned a Null value because only variables of type Variant
can be Null. Change to...

If IsNull(Me![contract subform]!CSO.Value) Then...

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net