Empty String

M

Murray

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
 
R

Rick Brandt

Murray said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top