Empty String

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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...
 
Back
Top